Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use HashMap in Hibernate?

 
necati sekkeli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I like to use HashMap in our software instead of Set but can not find a way for that. Can we only use set, bag and list? If we can use HashMap how can we define that in our XML files. Can you help please?

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to use HashMap? What would you use as your key?
 
necati sekkeli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the previously coded software uses hashMap and it will be too costly if we will try to change that design. It uses Serializable and User Defined parameter as variable.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by necati sekkeli:
Because the previously coded software uses hashMap and it will be too costly if we will try to change that design. It uses Serializable and User Defined parameter as variable.


Not sure I follow what you mean by "Serializable and User Defined parameter"? Serializable is an interface.

The reason Hibernate does not use Maps is probably because all Hibernate POJO's are by definition self-identifying (indeed everything in a relational database is self-identifying). Because of this, there is no need for Maps, the key is redundant. I'm struggling to think of any aspect of a relational model which could lend itself to a key:value structure. That being said, I suppose you could extend Hibernate to allow Maps (it is open source after all, so add all you like) but I still don't see how it would be useful. Alternatively, you can get a Collection of values out of a Map easily. Its surely not too big a job to convert between Maps and Collections in your DAO layer?
[ August 31, 2005: Message edited by: Paul Sturrock ]
 
necati sekkeli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. I am able to see the big picture and got the solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic