-->
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.  [ 2 posts ] 
Author Message
 Post subject: ResultTransformer with SQL
PostPosted: Tue Dec 26, 2006 11:45 am 
Newbie

Joined: Tue Dec 19, 2006 12:19 pm
Posts: 4
Hi all,

I'm trying to use ResultTransformer with SQL,
with no success.

when i'm running the following in HQL, it works great:


Code:
List cachedResultList = new ArrayList();

Query qry = getSession().createQuery("select a as a, b as b, c as c from Some")
qry.setResultTransformer(Transformers.aliasToBean(SomeDTO.class));
ScrollableResults scrollableResults = query.scroll();

scrollableResults.first();
scrollableResults.scroll(5);

while (scrollableResults.next()) {
    Object[] rowObjects = scrollableResults.get();
   
    SomeDTO  transformedDTO = (SomeDTO)rowObjects[0];
    // [b]rowObjects.size() = 1[/b]
   
    cachedResultList.add(transformedDTO);
}


but, when i convert it to SQL,
the rowObjects holds 3 items per row(a, b and c columns)
instead of only 1, like in HQL after the transformation.
the SQL section :

Code:
List cachedResultList = new ArrayList();

SQLQuery qry = getSession().createSQLQuery("select A as a, B as b, C as c from T_SOME")
qry.setResultTransformer(Transformers.aliasToBean(SomeDTO.class));
ScrollableResults scrollableResults = query.scroll();

scrollableResults.first();
scrollableResults.scroll(5);

while (scrollableResults.next()) {
    Object[] rowObjects = scrollableResults.get();

    SomeDTO  transformedDTO = (SomeDTO)rowObjects[0];
    // [b]rowObjects.size() = 3[/b]
    // [b]will throw convertion error[/b]

    cachedResultList.add(transformedDTO);
}


why is that?
is there any known bug?

[/code]

_________________
!!!Sharik!!!


Top
 Profile  
 
 Post subject: Re: ResultTransformer with SQL
PostPosted: Fri May 27, 2011 7:51 am 
Newbie

Joined: Thu May 26, 2011 9:07 am
Posts: 4
I'm experiencing the same issue, I'm trying to obtain a ScrollableResults from a query I would like to handle with a transformer, is there any news?
thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.