hibernate - How to get ScrollableResults with Gorm DetachedCriteria? -


in hibernate can do:

// dc - detachedcriteria scrollableresults sr = dc.getexecutablecriteria(getsession()).scroll() 

but how same gorm detachedcriteria?

domainname.withsession { session ->     domainname.where {        // predicates     }.getexecutablecriteria(session).scroll() } 

code above fail, because method not exists.

updated: have found solution:

 def hibersession = holders.grailsapplication.maincontext.sessionfactory.currentsession  def hiberdc = hibernatecriteriabuilder.gethibernatedetachedcriteria(null, gormdc)  def sr = hiberdc.getexecutablecriteria(hibersession).scroll() 

but outgoing sql has no columns in query:

select domain_name ... ; 

updated: dug deeper , have found solution previous problem.

hiberdc.setprojection(null) 

why happens?

when pass detached criteria (gorm) gethibernatedetachedcriteria , detached criteria has no projections, new detached criteria (hibernate) have empty list of projections instead of null - proof.

well, of it?

hibernate expects null in projection generating columns self - proof

so, answer question be:

def currentsession = holders.grailsapplication.maincontext.sessionfactory.currentsession def hibernatedetachedcriteria = hibernatecriteriabuilder.gethibernatedetachedcriteria(null, gormdetachedcriteria) def criteria = hibernatedetachedcriteria.getexecutablecriteria(currentsession) if (!criteria.projection) criteria.projection = null def scrollableresults = criteria.scroll(scrollmode.forward_only) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -