-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: many to many over multiple columns
PostPosted: Fri Mar 09, 2007 4:54 pm 
Newbie

Joined: Thu Mar 08, 2007 6:20 pm
Posts: 2
Hello everybody,

I have a problem mapping part of my database mode and hope that somebody here can help me. I googled quite a bit on this, but I suspect that I use the wrong searchterms (since I have not found an answer yet).

I have the following database model:

Image

In the domainmodel, Series has a map of Attributes. No problem mapping that. Series also has a list of Books and a Book has a reference to its Series. Again, no problems. But now comes the tricky part. I want to be able to ask a Book the question "give me your value of this attribute of your series". So I e.g. want Book to have a Map with 'Attribute' as key and 'value' as value.

I have no idea how to map this. Help... :)

With kind regards,

Martijn Onderwater (The Netherlands)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 10, 2007 11:00 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Have a look at http://www.hibernate.org/hib_docs/v3/re ... ns-ternary to see instructions about how to map a Map.

If you can afford it, the book "Java Persistence with Hibernate" (see above) will also provide you with a comprehensive explanation about this (and lots of other things :)).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 10, 2007 4:04 pm 
Newbie

Joined: Thu Mar 08, 2007 6:20 pm
Posts: 2
Hi Batmat,

This would indeed work. I could introduce an entity SeriesAttribute into my domainmodel, with a reference to a Series and an Attribute in it. The table 'tb_book_attribute_values' would then be a normal many-to-many relation.

But I don't really want to introduce an entity into my domainmodel just in order to get Hibernate to work. Of course, I will do it if it is the only to get my databasemodel mapped with Hibernate. But I'll just look a little further for now.

Does anybody have any more ideas?

/Martijn


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.