-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: fetching scroll not possible with native SQL?
PostPosted: Fri Mar 16, 2012 5:18 pm 
Beginner
Beginner

Joined: Wed Jun 15, 2005 1:28 pm
Posts: 39
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.
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.