Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Enities in hashmap

 
smitha eliz joshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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..
 
smitha eliz joshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic