tags:

views:

27

answers:

1

Hi! I have some class C that contains Map<A, Set<B>>, where A and B has long id and mapped in tables a and b. I want do some mapping of C into table with 2 attributes a_id and b_id. How can I do it? Thanks.

A: 

I am not positive I understood you question correctly, but if I did you could try the following.

Create a new table that has 3 columns, a_id, b_id, and c_id where only c_id cannot be null. Every entry in that table will represent a mapping from c -> {a || b}. In hibernate you will have a ManyToMany set or list of a's and b's in the c class.

twolfe18
Ooops! There is some error. I'm meaning, Map<A, Set<B>> instead Map<A, B>. And I couldn't write .hbm.xml for it(
Pier