-->
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.  [ 1 post ] 
Author Message
 Post subject: Creating a subclass with a not-null constraint
PostPosted: Tue Sep 27, 2005 10:25 am 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
I have a simple model in which I have a base class A and a subclass (discriminated) B. The B configuration specifies a not-null many-to-one relationship.

This result in a single table A which contains a NOT-NULL foreign-key for the many-to-one relationship. Since that many-to-one only exists for subclass B, I get a constraint violation when I try to save instances of class A (no many-to-one relationship specified). I don't want to make the relationship nullable and I don't want to use joined-subclass. I am using Sql Server and it would be great if somehow I could add a Check Constraint expression that will ensure that if the disctriminator is 'B', the foreign key relationship is not null.

Is this possible or is there some other way to achieve this.

thanks,
craig


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

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.