aspose file tools*
The moose likes Object Relational Mapping and the fly likes Getting Enities in hashmap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting Enities in hashmap" Watch "Getting Enities in hashmap" New topic
Author

Getting Enities in hashmap

smitha eliz joshi
Greenhorn

Joined: Aug 30, 2012
Posts: 6
hi,

I am new to Hibernate and my query is retrieving entities.

Entity has simple string properties.

one of the property is key (id). I need these entities as detached & need to do read only.

I am thinking to put these entities in hashmap & using id property as key in hashmap.

I am thinking to do it in Java (iterate collection of entities & save in hashmap).

I believe this is not correct way & there would be way to get the retrieved collection in hashmap directly.

Can you please suggest key-word to google I should look for to read on this OR any link/example to this case ?

regards.
lokesh sree
Ranch Hand

Joined: Oct 27, 2009
Posts: 100

"Iterating over the entities and saving them into the required HashMap or whatever collection". This seems to be fine and I don't see anything wrong with this approach.
Though I have not tried, the following links to seems to talk about returning a map from the queries...
http://stackoverflow.com/questions/3292597/how-to-get-java-util-map-from-hibernate-query
http://stackoverflow.com/questions/925363/how-to-fetch-hibernate-query-result-as-associative-array-of-list-or-hashmap

Hope that helps..


Lokesh
( SCBCD 5, CCENT, SCJP 5 )
smitha eliz joshi
Greenhorn

Joined: Aug 30, 2012
Posts: 6
lokesh chenta wrote:"Iterating over the entities and saving them into the required HashMap or whatever collection". This seems to be fine and I don't see anything wrong with this approach.
Though I have not tried, the following links to seems to talk about returning a map from the queries...
http://stackoverflow.com/questions/3292597/how-to-get-java-util-map-from-hibernate-query
http://stackoverflow.com/questions/925363/how-to-fetch-hibernate-query-result-as-associative-array-of-list-or-hashmap

Hope that helps..

thanks for your reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Enities in hashmap