-->
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: one-to-one using a foreing key with unique constraint
PostPosted: Fri Dec 10, 2004 12:52 pm 
Newbie

Joined: Thu Jul 15, 2004 1:07 pm
Posts: 9
Hibernate version: 2.1

Name and version of the database you are using: mysql 4.1.7

I am trying to map a one to one relationship from A to B, where B has a foreign key a_id, which is the primary key of A.

I am using many-to-one relationship (as discussed in Chapter 5 of the documentation: Basic O/R Mapping):

<many-to-one
name="B"
class="com.me.B"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="a_id"
unique="true"
/>

My question is, can the foreign key (a_id) in table B be null? In my application it can be null (needs to be null), but I get a hibernate lazy initialization exception when I try this.

I can't use a straight one-to-one because A and B are both joined-sublcasses of a similar parent.

Thanks,
Jay


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 12:59 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
set not-null="false" in many-to-one

reference isn't updated and not-null doesn't exists in refernece, but it is legal

regards
Peco


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.