-->
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.  [ 3 posts ] 
Author Message
 Post subject: Running ResultTransformer on HQL queries
PostPosted: Wed Apr 20, 2005 10:52 am 
Newbie

Joined: Thu Feb 05, 2004 9:32 am
Posts: 7
Hi all,

What I want to do:
I am trying to execute HQL "select cat.id, cat.name from Cat cat", and it should return partially filled Cat objects, like Criteria projections with ResultTransformer.

I wonder, if this is even possible with current Hibernate versions (3.0.1). I saw that getReturnAliases() has been added to Query API, but there is still no setResultTransformer() method. Does anyone have expierence with this? Would it make sense to subclass AliasToBeanResultTransformer and add something like this?

Code:
transformList(List original, String[]returnAlias);


I would appreciate any ideas or comments.


Thanks,
John


Top
 Profile  
 
 Post subject: Re: Running ResultTransformer on HQL queries
PostPosted: Wed Apr 20, 2005 2:23 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
blackDoggy wrote:
Hi all,

What I want to do:
I am trying to execute HQL "select cat.id, cat.name from Cat cat", and it should return partially filled Cat objects, like Criteria projections with ResultTransformer.

I wonder, if this is even possible with current Hibernate versions (3.0.1). I saw that getReturnAliases() has been added to Query API, but there is still no setResultTransformer() method. Does anyone have expierence with this? Would it make sense to subclass AliasToBeanResultTransformer and add something like this?

Code:
transformList(List original, String[]returnAlias);


I would appreciate any ideas or comments.


Thanks,
John


If you create a specialized constructor, you can perform the following HQL Query to return partially filled Cat objects.
Code:
session.createQuery("select new Cat(cat.id, cat.name) from Cat cat").list();


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 20, 2005 5:32 pm 
Newbie

Joined: Thu Feb 05, 2004 9:32 am
Posts: 7
pksiv, this is an good option, however, in my case it won't work - I would have to create far too many different constructors for my Cats!


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