-->
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 based on FK with cascade=all
PostPosted: Tue Dec 02, 2003 5:43 am 
Newbie

Joined: Wed Oct 08, 2003 11:27 am
Posts: 18
I have a one-to-one mapping based on a foreign key

Code:
CONTENT {
ID NUMBER(16),
XML_CONTENT BLOB
}

ARTICLE {
ID NUMBER(16)
NAME VARCHAR2,
ID_CONTENT,
FOREIGN KEY(ID_CONTENT) REFERENCES CONTENT
}

My mappings are:
In Content:
Code:
<one-to-one name="article" class="de.ems.cms.beans.Article"
property-ref="content" constrained="true"/>


In Article:
Code:
<many-to-one name="content" class="de.ems.cms.beans.Content"
column="ID_CONTENT" unique="true" cascade="all"/>


I create an Article (a) and a Content(c), I use
Code:
a.setContent(c);

and when I try to save I get the following error.
Shouldn't the Content be save automatically because of cascade="all"?

net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: net.sf.hibernate.persister.EntityPersister.article
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: net.sf.hibernate.persister.EntityPersister.article
at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1206)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:871)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:815)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:738)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:715)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1317)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:841)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:815)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:738)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:715)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1317)
........................

Thanks,

Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 6:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
article cannot be null if constrained="true"


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.