-->
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: how to fetch selected columns as value object using HQL.
PostPosted: Thu Sep 01, 2005 10:54 am 
Newbie

Joined: Thu Sep 01, 2005 10:35 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: SQL Server

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi All,
When i want to fetch selected columns from an entity through HQL
and write query in HBM file , then i get the object array as result.
But i want to get value object as result through HQL (not native query) and write the query in hbm file .

so plz help me.

Amit Jain


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is the problem ?

if you select multiple values then you of course get an array...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: how to fetch selected columns as value object using HQL.
PostPosted: Thu Sep 01, 2005 2:33 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
You can also create a constructor that takes the attributes you are selecting and specify your HQL as follows :

Code:
select new MyObject(moo.id,moo.someField, moo.someOtherField) from MyOtherObject as moo;

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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.