-->
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: Parent/Child mapping of value type object
PostPosted: Thu Mar 12, 2009 12:43 pm 
Newbie

Joined: Thu Mar 12, 2009 9:40 am
Posts: 2
Hi,

I am having difficulties understanding mapping parent/child relationships using embedded value type objects, i'll try to explain my situation:

Parent
parent_id -> PK
.
.
.


Child
parent_id -> FK to Parent
covid
.
.
.

In Child parent_id and covid is a composite PK, the child table has more columns, some of which are nullable. There is a one-to-many relationship between parent and child. A parent cannot have more than one child with the same covid. I have been reading the book Java Persistence with Hibernate and it states that to use child as en embedded value type object all columns must be a composite primary key but thats not my case as the composite key is parent_id and covid, also it says I could add a surrogate key to the table to avoid this but I cannot modify the schema. Is there a way I can create this relationship without making child a full entity?

Thanks,
Angel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 12, 2009 4:08 pm 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
The value type belongs to an entity, and its persistent state is embedded in the table row of the owning entity. So I think Child can't be a value type since it has its own table.

LinHib.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 13, 2009 9:33 am 
Newbie

Joined: Thu Mar 12, 2009 9:40 am
Posts: 2
I think you're right when it comes to the jpa spec, but hibernate does allow this through the CollectionOfElements annotation if I'm not mistaken.

-Angel


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.