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]