Hi,
It seems that criteria.setFetchMode gets ignored if you combine it with createCriteria to add a restriction.
This works as expected:
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
But in this case the join doesn't happen (and I get a LazyInstantiationException further on).
DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
c.createCriteria("menuItemSubscriptions").add(
Restrictions.eq("location", "B")
);
This does not happen if I set lazy="false" in the mappings
file.
Regards,
Peter
Hibernate 3.2.5, Oracle 8
This is working for me with 4.3.0.
I had the same problem with MySql until I added useOldAliasMetadataBehavior=true to the connection string.
jdbc:mysql://localhost:3306/foobar?useOldAliasMetadataBehavior=true
Cheers.
In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.
If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.
Thank you!
Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!
@Brett
A lot of projects still have a strong dependency on ORM 3 (e.g. as of Grails 2.3.9 a lot of important plugins only support Hibernate3).
For example, this bug renders the fetch joins expressed as Grails queries unusable (https://jira.grails.org/browse/GRAILS-9829)
It would be very nice if this bug could be fixed in ORM 3 (I believe it works in ORM 4).
I am willing to create a test case if you think it is realistic that this gets fixed (Stian Brattland's example is fairly straightforward)
Sorry , but ORM 3 hasn't been maintained for quite some time. If there's still an issue in ORM 4, we'd be happy to take a look there, provided there's a test case that we could use to reproduce it.