[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7226) Result transformer set on Query is ignored

Rafal Figas (JIRA) noreply at atlassian.com
Thu Apr 5 11:32:48 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-7226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46194#comment-46194 ] 

Rafal Figas commented on HHH-7226:
----------------------------------

I've just discovered that transformer is applied, however in some strange way.

Running:

String queryStr = "select a from A a [some clauses that cause non-distinct results]";
Query query = getSession().createQuery(queryStr);
return DistinctResultTransformer.INSTANCE.transformList(query.list());

causes return of list of five objects of type A.

However running:

String queryStr = "some query";
Query query = getSession().createQuery(queryStr);
query.setResultTransformer(DistinctResultTransformer.INSTANCE);
return query.list();

will also cause return of list of five objects, however those object will be of class Object and cannot be cast to A.


> Result transformer set on Query is ignored
> ------------------------------------------
>
>                 Key: HHH-7226
>                 URL: https://hibernate.onjira.com/browse/HHH-7226
>             Project: Hibernate ORM
>          Issue Type: Bug
>    Affects Versions: 3.6.9
>            Reporter: Rafal Figas
>            Priority: Minor
>
> When something like this is done:
> String queryStr = "some query";
> Query query = getSession().createQuery(queryStr);
> query.setResultTransformer(DistinctResultTransformer.INSTANCE);
> then query.list() is not transformed by given transformer.
> Workaround exists:
> DistinctResultTransformer.INSTANCE.transformList(query.list());

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list