-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to persist a Collection which contains different types
PostPosted: Tue Sep 16, 2003 12:37 pm 
Newbie

Joined: Tue Sep 16, 2003 12:17 pm
Posts: 1
Hi

I try to persist a Collection which contains different types of classes.

E.g.. Products: Books, Lighters, Sausages, ...

What should I use?

-The <any> tag.
-The <subclass> or <joined-subclass>.

Some example hibernate-mapping-files?

Thanx
montsie


Top
 Profile  
 
 Post subject: Collections of many types of items
PostPosted: Tue Sep 16, 2003 6:56 pm 
Regular
Regular

Joined: Tue Sep 09, 2003 9:37 pm
Posts: 56
Location: Ogden, Utah, USA
It depends on how your data is modeled. If Books, lighters, sausages, etc. are all in one table (product) then you'd probably want a subclass. You would need a discriminator column in the table to tell hibernate which type of class to construct when loading them. The documentation has some examples of hibernate mappings.

If your items have a common database table, but additional information in a different table for each class then you should use a joined-subclass I think.

Good luck!
Jenica


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.