I am using JBoss 6.0 with Hibernate Core 3.6. To solve a particular problem, we tried to use a native sql query to load a root entity with a collection property, and scroll through it.
Code:
org.hibernate.Query q = session.createSQLQuery("...[select statement with joins to collections]...")
query.addFetch("alias", "owner", "property")
ScrollableResults scroll = q.scroll()
The collection was only populated with the first item in the collection. The root cause was a class called CustomLoader used in returning results, which does not override a method from the parent class Loader written to return a hard coded result:
Code:
/**
* Does the result set to be scrolled contain collection fetches?
*
* @return True if it does, and thus needs the special fetching scroll
* functionality; false otherwise.
*/
protected boolean needsFetchingScroll() {
return false;
}
Calling scroll() puts you in Loader.java:2590. It will always return ScrollableResultImpl at 2628 due to needsFetchingScroll always being false, instead of giving us an instance of FetchingScrollableResultsImpl to return our populated collections.
I'm curious if this a known and intentional limitation at this release?