-->
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: Any mapping
PostPosted: Wed Sep 02, 2009 11:50 am 
Newbie

Joined: Wed Sep 02, 2009 11:40 am
Posts: 1
Hi,

I have the table 'Attribute' that contains the entity_id and entity_type_id, the entity can be 'Product' or 'Category' (product or category may have many attributes). The entity_id is referred to the product_id or category_id, and the entity_type_id referred to 'Entity_Type' table. How can I map this association. Look like I have to use the 'any' mapping, does anyone has the experience on this? How can I get the attributes from the product or category, and insert the attributes when insert the product or category (cascade save)?

Any help would appreciate!
Thanks


Top
 Profile  
 
 Post subject: Re: Any mapping
PostPosted: Wed Sep 02, 2009 6:21 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You'll want to look into inheritance mapping with Hibernate and JPA. Here's a little tutorial on mapping inheritance hierarchies:

http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=16mappinginheritancewithjpa

When you get your object model mapped, then take a look at performing polymorphic queries with Hibernate.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.