• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Hibernate] Mapping key/value pairs in a HashMap

 
Xavier Shay
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly new to all this and am having a conceptual problem. I've been wading through documentation, but I'm not even sure where I'm supposed to be looking anymore :S

I had an idea that if I use a base class as below, then users could subclass it for there own logic (storing all data in the map rather than instance variables), and hibernate would be able to persist it without changing the DB structure using a single_table inheritance strategy.

1) Is this idea valid?
2) What association is needed to persist the map? It's a component, right? I was thinking a schema along these lines:
Discount
- Id
DiscountParameter
- DiscountId (foreign key to Discount)
- Key
- Value

I've tried a heap of different things, but can't quite get my head around how OneToMany or ManyToMany relates to this situation.

Thanks,
- Xavier


I posted this on the Hibernate Users forum to no avail
 
Mohd. Yakub
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shay,

A very nice article on this,
http://www-128.ibm.com/developerworks/java/library/j-hibernate/


regards,
yakub
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic