• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate mapping HashMap to row

 
Gary
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I have a HashMap() with key1, value1..key2,value2...etc
I want to map this to a relational table with columns
key1,key2,..,key n
value1,value2..,val n

Could you show me how to with mapping configuration for hibernate? (.hbm.xml)

Thanks in advance,
Gaurav
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Tom cruise"

Please check your private messages again.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, three warnings and still not the correct Naming Policy. I am sorry but I am going to close your account.

Thank you

Mark Spritzler
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I will answer your question.

Hibernate doesn't map that way, I am sorry.

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you can create an Interceptor that you write all the code to convert the data from the ResultSet to your Map, but in that case you are just better off using JDBC.

Mark
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

Care to show a rough sketch? PLEASE DON'T POST THE CODE! ( ). this is a weird problem

Regards,
Vyas, Anirudh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anirudh Vyas:
Mark,

Care to show a rough sketch? PLEASE DON'T POST THE CODE! ( ). this is a weird problem

Regards,
Vyas, Anirudh


How about Javadocs, and a link to Hibernate Documentation on it.

Javadoc for Interceptor interface
http://www.hibernate.org/hib_docs/v3/api/

Other Doc
http://www.hibernate.org/hib_docs/v3/reference/en/html/events.html

Good Luck

Mark
 
Anirudh Vyas
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know what an interceptor is, we use it for audit logging all the time, but how would a hashmap's keys be convertible to columns and values as he put it in the post (original post)? thats what i was wondering about ...



Regards
Vyas, Anirudh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the two corresponding interface methods of Interceptor. In the reading one, he takes the JDBC ResultSet and converts it into the Hashmap. In the writing, he takes the Hashmap and writes the query to load it into the database, one for update and one for insert.

I will not write any of the code or show more detail.

How to call get() and put() on a Map is not my concern in this forum

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic