Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: fetching scroll not possible with native SQL?
PostPosted: Fri Mar 16, 2012 5:18 pm 

Joined: Wed Jun 15, 2005 1:28 pm
Posts: 34
Location: United States
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.
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:
    * 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?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.