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:
nandina 2010-11-04 17:20:39 +05:30 committed by adamw
parent 97f8ceac9b
commit 696fcccd0f
5 changed files with 19 additions and 8 deletions

View File

@ -65,7 +65,10 @@ public class BasicCollectionInitializor<T extends Collection> extends AbstractCo
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
protected void addToCollection(T collection, Object collectionRow) { 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 the target entity is not audited, the elements may be the entities already, so we have to check
// if they are maps or not. // if they are maps or not.

View File

@ -63,13 +63,17 @@ public class ListCollectionInitializor extends AbstractCollectionInitializor<Lis
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
protected void addToCollection(List collection, Object collectionRow) { 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 ? Object element = elementData instanceof Map ?
elementComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, elementComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
(Map<String, Object>) elementData, null, revision) (Map<String, Object>) elementData, null, revision)
: elementData ; : elementData ;
Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex());
Object indexObj = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, Object indexObj = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
(Map<String, Object>) indexData, element, revision); (Map<String, Object>) indexData, element, revision);
int index = ((Number) indexObj).intValue(); int index = ((Number) indexObj).intValue();

View File

@ -67,11 +67,15 @@ public class MapCollectionInitializor<T extends Map> extends AbstractCollectionI
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
protected void addToCollection(T collection, Object collectionRow) { 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, Object element = elementComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
(Map<String, Object>) elementData, null, revision); (Map<String, Object>) elementData, null, revision);
Object indexData = ((List) collectionRow).get(indexComponentData.getComponentIndex());
Object index = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator, Object index = indexComponentData.getComponentMapper().mapToObjectFromFullMap(entityInstantiator,
(Map<String, Object>) indexData, element, revision); (Map<String, Object>) indexData, element, revision);

View File

@ -75,7 +75,7 @@ public final class OneAuditEntityQueryGenerator implements RelationQueryGenerato
// SELECT new list(e) FROM versionsEntity e // SELECT new list(e) FROM versionsEntity e
QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e"); QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e");
qb.addProjection("new list", "e", false, false); qb.addProjection(null, "e", false, false);
// WHERE // WHERE
Parameters rootParameters = qb.getRootParameters(); Parameters rootParameters = qb.getRootParameters();
// e.id_ref_ed = :id_ref_ed // e.id_ref_ed = :id_ref_ed

View File

@ -75,7 +75,7 @@ public final class OneEntityQueryGenerator implements RelationQueryGenerator {
// SELECT new list(ee) FROM middleEntity ee // SELECT new list(ee) FROM middleEntity ee
QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee"); QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee");
qb.addProjection("new list", "ee", false, false); qb.addProjection(null, "ee", false, false);
// WHERE // WHERE
Parameters rootParameters = qb.getRootParameters(); Parameters rootParameters = qb.getRootParameters();
// ee.originalId.id_ref_ing = :id_ref_ing // ee.originalId.id_ref_ing = :id_ref_ing