-->
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.  [ 4 posts ] 
Author Message
 Post subject: project result set into Map
PostPosted: Mon Jun 13, 2005 9:26 am 
Newbie

Joined: Tue Jun 07, 2005 3:38 am
Posts: 3
Location: Timisoara Romania
Hi there,

I'm kind of new to Hibernate and want to implement a generic query, like specifying a number of column names, and get the result into a Map, as columnName, value pairs. Of course this Map object would represent a row from the database, and these Maps would be placed into a List.

Can i use the projection feauture of Hibernate to implement this generic query? what else can i use?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 12:05 am 
Beginner
Beginner

Joined: Mon Jun 13, 2005 5:52 pm
Posts: 43
Are you looking for something like:

http://www.hibernate.org/hib_docs/v3/re ... hql-select

Remember that Hibernate doesn't deal with "columns" from your applciation's standpoint--it works with properties and associations.

You can also use the Criteria API to perform projections. In general, projections are more for aggregate queries.

http://www.hibernate.org/hib_docs/v3/re ... projection

If you need a list of User objects, for example, simply create a query that returns those objects. The properties will be all populated for you, and associations will be looked up lazily.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 1:38 am 
Newbie

Joined: Tue Jun 07, 2005 3:38 am
Posts: 3
Location: Timisoara Romania
I'm looking for something like the following: specify a list of property names mapped to a table's columns, to be the property values needed as result, and a condition, and get the values for the specifyied properties into a Map containing pairs of (propertyName, propertyValue).

Is it possible to do this kind of query? i know JDO can, and would love to be able to do this with Hibernate too.

http://www.theserverside.com/articles/a ... QueryPart2
"Projection into a concrete Map implementation"

Thanks for your interest


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 8:38 am 
Beginner
Beginner

Joined: Mon Jun 13, 2005 5:52 pm
Posts: 43
Sorry, I don't know of the answer myself. Post the answer here if you find it.


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