-->
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: JPA "one to many" relation question
PostPosted: Mon Feb 04, 2008 10:15 am 
Newbie

Joined: Mon Dec 11, 2006 12:16 pm
Posts: 2
Location: Belgium
Hi all,

I'm using JPA with hibernate 3.3 and I'd like to make a one to many/many to one bidirectional relation.

the trouble is that I do not know how to tell JPA I want at least one element in the many side.
-> one TO at least one element relation...

can you help me?

thanks in advance,
Mike.


Top
 Profile  
 
 Post subject: Re: JPA "one to many" relation question
PostPosted: Mon Feb 04, 2008 10:36 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
I am wondering if you could use an interceptor to check this. The interceptor can throw an exception if the collection is empty.


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 10:42 am 
Regular
Regular

Joined: Mon Aug 20, 2007 6:47 am
Posts: 74
Location: UK
I don't think you can enforce that with JPA/Hibernate mappings. I'm not sure you can enforce it at the database level either without the use of triggers.

Can you initialise the child relationship in the parent's no-arg constructor?


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.