diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java index 28f16e21cf..97eb7d6036 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/BasicCollectionInitializor.java @@ -65,7 +65,10 @@ public class BasicCollectionInitializor extends AbstractCo @SuppressWarnings({"unchecked"}) protected void addToCollection(T collection, Object collectionRow) { - Object elementData = ((List) collectionRow).get(elementComponentData.getComponentIndex()); + Object elementData = collectionRow; + if (collectionRow instanceof java.util.List) { + elementData = ((List) collectionRow).get(elementComponentData.getComponentIndex()); + } // If the target entity is not audited, the elements may be the entities already, so we have to check // if they are maps or not. diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java index 583afd5953..262b95a04f 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/ListCollectionInitializor.java @@ -63,13 +63,17 @@ public class ListCollectionInitializor extends AbstractCollectionInitializor) elementData, null, revision) : elementData ; - Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex()); Object indexObj = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, (Map) indexData, element, revision); int index = ((Number) indexObj).intValue(); diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java index e7a4ed44f6..8dfbf811e3 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/lazy/initializor/MapCollectionInitializor.java @@ -67,14 +67,18 @@ public class MapCollectionInitializor extends AbstractCollectionI @SuppressWarnings({"unchecked"}) protected void addToCollection(T collection, Object collectionRow) { - Object elementData = ((List) collectionRow).get(elementComponentData.getComponentIndex()); + Object elementData = collectionRow; + Object indexData = collectionRow; + if (collectionRow instanceof java.util.List) { + elementData = ((List) collectionRow).get(elementComponentData.getComponentIndex()); + indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex()); + } Object element = elementComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, (Map) elementData, null, revision); - Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex()); Object index = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, (Map) indexData, element, revision); collection.put(index, element); } -} \ No newline at end of file +} diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java index ad204fbdd4..7528dd0ff5 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneAuditEntityQueryGenerator.java @@ -75,7 +75,7 @@ public final class OneAuditEntityQueryGenerator implements RelationQueryGenerato // SELECT new list(e) FROM versionsEntity e QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e"); - qb.addProjection("new list", "e", false, false); + qb.addProjection(null, "e", false, false); // WHERE Parameters rootParameters = qb.getRootParameters(); // e.id_ref_ed = :id_ref_ed diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java index 565750d790..e4310e87ba 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/entities/mapper/relation/query/OneEntityQueryGenerator.java @@ -75,7 +75,7 @@ public final class OneEntityQueryGenerator implements RelationQueryGenerator { // SELECT new list(ee) FROM middleEntity ee QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee"); - qb.addProjection("new list", "ee", false, false); + qb.addProjection(null, "ee", false, false); // WHERE Parameters rootParameters = qb.getRootParameters(); // ee.originalId.id_ref_ing = :id_ref_ing