Fix for HHH-5686 Changed the generation of HQL query for one to many relations from "select new list(r) from Relation r" to "select r from Relation r".
This commit is contained in:
parent
97f8ceac9b
commit
696fcccd0f
|
@ -65,7 +65,10 @@ public class BasicCollectionInitializor<T extends Collection> 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.
|
||||
|
|
|
@ -63,13 +63,17 @@ public class ListCollectionInitializor extends AbstractCollectionInitializor<Lis
|
|||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
protected void addToCollection(List 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 = elementData instanceof Map ?
|
||||
elementComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
|
||||
(Map<String, Object>) elementData, null, revision)
|
||||
: elementData ;
|
||||
|
||||
Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex());
|
||||
Object indexObj = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
|
||||
(Map<String, Object>) indexData, element, revision);
|
||||
int index = ((Number) indexObj).intValue();
|
||||
|
|
|
@ -67,14 +67,18 @@ public class MapCollectionInitializor<T extends Map> 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<String, Object>) elementData, null, revision);
|
||||
|
||||
Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex());
|
||||
Object index = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
|
||||
(Map<String, Object>) indexData, element, revision);
|
||||
|
||||
collection.put(index, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue