[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1570) criteria-api: filtering by key-many-to-one causes invalid sql
Yoann Antoviaque (JIRA)
noreply at atlassian.com
Mon Feb 6 08:21:10 EST 2012
[ https://hibernate.onjira.com/browse/HHH-1570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45373#comment-45373 ]
Yoann Antoviaque commented on HHH-1570:
---------------------------------------
I looked at this issue, the experimental patch did not resolve the problem in our case, I had to modify it (will post it later today, once I have validated that it works completly for us).
I still have a "regression" in FumTest#testKeyManyToOne() but I think it is not a regression but another bug that was hidden due to the absence of loading of linked tables:
by adding those lines in FumTest#testKeyManyToOne(), i get a NonUniqueObjectException, failing exactly the same way, even with a non patched hibernate-core:
// new test case showing non refreshed composite keys
s = openSession();
InnerKey sid2 = new InnerKey();
sid2.setAkey("a");
sid2.setBkey("b");
Inner sup2 = (Inner) s.load(Inner.class, sid2);
assertEquals("dudu", sup2.getDudu());
MiddleKey mid2 = new MiddleKey();
mid2.setOne("one");
mid2.setTwo("two");
mid2.setSup(sup);
Middle m2 = (Middle) s.load(Middle.class, mid2);
assertEquals("bla", m2.getBla());
d = (Outer) s.load(Outer.class, did);
assertTrue( d.getId().getMaster().getId().getSup().getDudu().equals("dudu") );
s.delete(d);
s.delete( d.getId().getMaster() ); //we do not get the master from session but the one from did, therefore fail with NonUniqueObjectException !
s.save( d.getId().getMaster() );
s.save(d);
s.flush();
s.connection().commit();
s.close();
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: https://hibernate.onjira.com/browse/HHH-1570
> Project: Hibernate ORM
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.5.3, 3.6.0.Beta1
> Reporter: Joris Verschoor
> Assignee: Steve Ebersole
> Attachments: HHH-1570-fix.patch, HHH-1570-it.patch, hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
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