[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2312) criteria with annotation mapping leads to bad join on a 1:n:n relation
Sebastian Hennebrueder (JIRA)
noreply at atlassian.com
Fri Dec 15 17:19:04 EST 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2312?page=comments#action_25641 ]
Sebastian Hennebrueder commented on HHH-2312:
---------------------------------------------
I forgot to say that I tested this against Hibernate from SVN revision 10998 with the same result.
You can test this by changing the hibernate.cfg.xml It includes both types of mapping.
> criteria with annotation mapping leads to bad join on a 1:n:n relation
> ----------------------------------------------------------------------
>
> Key: HHH-2312
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2312
> Project: Hibernate3
> Type: Bug
> Versions: 3.2.1
> Environment: Ubuntu Linux
> PostgreSQL 8.0 database
> Reporter: Sebastian Hennebrueder
> Attachments: HibernateTest.zip
>
>
> I have a 1:n to 1:n relation, ie. Forest has many Trees has many Leafs.
> I try to select all Trees having a leaf which name is test.
> session.createCriteria(Tree.class).createCriteria("leafs").add(Restrictions.eq("name", "test")).list();
> If I use XML mapping, I receive a proper query:
> select this_.id as id1_1_, leaf1_.id as id0_0_, leaf1_.name as name0_0_, leaf1_.tree_id as tree3_0_0_
> from tree this_ inner join leaf leaf1_ on this_.id=leaf1_.tree_id where leaf1_.name=?
> but if I use annotation mapping, I get a very ugly join returning not even the correct values:
> select this_.id as id2_3_, this_.forest_id as forest2_2_3_, leaf1_.id as id0_0_, leaf1_.tree_id as tree3_0_0_,
> leaf1_.name as name0_0_, tree4_.id as id2_1_, tree4_.forest_id as forest2_2_1_, forest5_.id as id1_2_
> from Tree
> this_ inner join Leaf leaf1_ on this_.id=leaf1_.tree_id
> left outer join Tree tree4_ on leaf1_.tree_id=tree4_.id
> left outer join Forest forest5_ on tree4_.forest_id=forest5_.id where leaf1_.name=?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list