[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-6518) Request malformed on a left fetch join subItem.myCollection (double outer join) : uncorrect fromElementList, can't find the associated collectionOwner and initialize a proxy on an empty fetched collection
Quentin Ambard (JIRA)
noreply at atlassian.com
Fri Jul 29 14:22:02 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6518?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Quentin Ambard updated HHH-6518:
--------------------------------
Attachment: CORRECThibernateTestCase.tar.gz
I forget to remove an old class "Container" from the previous mapping test case. This one is the correct one.
> Request malformed on a left fetch join subItem.myCollection (double outer join) : uncorrect fromElementList, can't find the associated collectionOwner and initialize a proxy on an empty fetched collection
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-6518
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6518
> Project: Hibernate Core
> Issue Type: Bug
> Components: core, query-sql
> Affects Versions: 3.6.6, 4.0.0.Beta4
> Reporter: Quentin Ambard
> Labels: HQL, Parser, proxy
> Attachments: CORRECThibernateTestCase.tar.gz, hibernateTestCase.tar.gz
>
>
> There is an error fetching a collection of a subitem.
> This affect empty collections : a proxy is intialized on the collection, even fetched. Accessing to this collection fire a new request.
> Here is a simple mode. Please see test case for complete implementation:
> @Entity
> @Table( name = "ITEM" )
> public class Item {
> @Id
> @GeneratedValue
> private Long id;
> @OneToOne(cascade = { CascadeType.ALL }, optional = true, fetch = FetchType.LAZY, orphanRemoval = true)
> @JoinColumn(name = "SUB_ITEM_ID")
> private SubItem subItem ;
> ...
> }
> public class SubItem {
> @Id
> @GeneratedValue
> private Long id;
>
>
> @ElementCollection(targetClass = String.class, fetch = FetchType.LAZY)
> @CollectionTable(name = "PHONES")
> @Column(name = "PHONE", nullable = false)
> private List<String> phones ;
> ...
> }
> the following hql request "from Item i left join fetch i.subItem left join fetch i.subItem.phones" generates this sql request :
> select item0_.id as id2_0_, subitem1_.id as id1_1_, item0_.SUB_ITEM_ID as SUB2_2_0_, phones3_.SubItem_id as SubItem1_1_0__, phones3_.PHONE as PHONE0__, phones3_.SubItem_id as SubItem1_1_0__, phones3_.PHONE as PHONE0__
> from ITEM item0_
> left outer join SUB_ITEM subitem1_ on item0_.SUB_ITEM_ID=subitem1_.id
> left outer join SUB_ITEM subitem2_ on item0_.SUB_ITEM_ID=subitem2_.id
> left outer join PHONES phones3_ on subitem2_.id=phones3_.SubItem_id
> There is an extra left outerjoin.
> QueryClassLoader.initialize(SelectClause selectClause) can't find the collectionOwner for the PHONES collection :
> collectionFromElement.getOrigin()is about the second left outer join : "SUB_ITEM subitem2_ on item0_.SUB_ITEM_ID=subitem2_.id" and the fromElementList is based on the first outer join "subitem1_ on item0_.SUB_ITEM_ID=subitem1_.id".
> The following hql request doesn't work either :
> from Item i left join fetch i.subItem s left join fetch s.phones
> Request is correctly generated, but the left outer join collectionPersisters is null
> java.lang.NullPointerException
> at org.hibernate.loader.BasicLoader.isBag(BasicLoader.java:97)
> at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:76)
> at org.hibernate.loader.hql.QueryLoader.<init>(QueryLoader.java:120)
> at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:204)
> ...
> see attached test case for full stack
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list