From bdae05272b16a4890681c4a2f89aa1613fe44c86 Mon Sep 17 00:00:00 2001 From: Haralds Ulmanis Date: Fri, 10 Jul 2015 16:23:20 +0100 Subject: [PATCH 1/2] fix #586 --- .../astyanax/entitystore/EntityMapper.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java b/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java index 6280207ca..4f06521fc 100644 --- a/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java +++ b/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java @@ -100,21 +100,25 @@ public EntityMapper(Class clazz, Integer ttl) { if ((columnAnnotation != null)) { field.setAccessible(true); ColumnMapper columnMapper = null; - Entity compositeAnnotation = field.getType().getAnnotation(Entity.class); - if (Map.class.isAssignableFrom(field.getType())) { - columnMapper = new MapColumnMapper(field); - } else if (Set.class.isAssignableFrom(field.getType())) { - columnMapper = new SetColumnMapper(field); - } else if(compositeAnnotation == null) { - if (columnAnnotation.unique()) { - Preconditions.checkArgument(tempUniqueMapper == null, "can't have multiple unique columns '" + field.getName() + "'"); - tempUniqueMapper = new LeafColumnMapper(field); - } - else { - columnMapper = new LeafColumnMapper(field); - } + if (field.getAnnotation(Serializer.class) != null) { + columnMapper = new LeafColumnMapper(field); } else { - columnMapper = new CompositeColumnMapper(field); + Entity compositeAnnotation = field.getType().getAnnotation(Entity.class); + if (Map.class.isAssignableFrom(field.getType())) { + columnMapper = new MapColumnMapper(field); + } else if (Set.class.isAssignableFrom(field.getType())) { + columnMapper = new SetColumnMapper(field); + } else if(compositeAnnotation == null) { + if (columnAnnotation.unique()) { + Preconditions.checkArgument(tempUniqueMapper == null, "can't have multiple unique columns '" + field.getName() + "'"); + tempUniqueMapper = new LeafColumnMapper(field); + } + else { + columnMapper = new LeafColumnMapper(field); + } + } else { + columnMapper = new CompositeColumnMapper(field); + } } Preconditions.checkArgument(!usedColumnNames.contains(columnMapper.getColumnName()), String.format("duplicate case-insensitive column name: %s", columnMapper.getColumnName().toLowerCase())); From d66c3cac4ff6dd231fd6206626b5caba2c91f003 Mon Sep 17 00:00:00 2001 From: Haralds Ulmanis Date: Fri, 10 Jul 2015 16:30:54 +0100 Subject: [PATCH 2/2] formatting --- .../astyanax/entitystore/EntityMapper.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java b/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java index 4f06521fc..5b78240c5 100644 --- a/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java +++ b/astyanax-entity-mapper/src/main/java/com/netflix/astyanax/entitystore/EntityMapper.java @@ -104,20 +104,20 @@ public EntityMapper(Class clazz, Integer ttl) { columnMapper = new LeafColumnMapper(field); } else { Entity compositeAnnotation = field.getType().getAnnotation(Entity.class); - if (Map.class.isAssignableFrom(field.getType())) { - columnMapper = new MapColumnMapper(field); - } else if (Set.class.isAssignableFrom(field.getType())) { - columnMapper = new SetColumnMapper(field); - } else if(compositeAnnotation == null) { - if (columnAnnotation.unique()) { - Preconditions.checkArgument(tempUniqueMapper == null, "can't have multiple unique columns '" + field.getName() + "'"); - tempUniqueMapper = new LeafColumnMapper(field); - } - else { - columnMapper = new LeafColumnMapper(field); - } + if (Map.class.isAssignableFrom(field.getType())) { + columnMapper = new MapColumnMapper(field); + } else if (Set.class.isAssignableFrom(field.getType())) { + columnMapper = new SetColumnMapper(field); + } else if(compositeAnnotation == null) { + if (columnAnnotation.unique()) { + Preconditions.checkArgument(tempUniqueMapper == null, "can't have multiple unique columns '" + field.getName() + "'"); + tempUniqueMapper = new LeafColumnMapper(field); + } + else { + columnMapper = new LeafColumnMapper(field); + } } else { - columnMapper = new CompositeColumnMapper(field); + columnMapper = new CompositeColumnMapper(field); } } Preconditions.checkArgument(!usedColumnNames.contains(columnMapper.getColumnName()),