-->
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: Mapping Bidirektional one-to-many cascade Problem
PostPosted: Mon Apr 25, 2005 10:17 am 
Newbie

Joined: Mon Apr 25, 2005 9:32 am
Posts: 2
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.01
I try this mapping but when I use the cascade Option I get an Exeception. Can anybody help me ?
Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="de.hybernate">
<class name="Tree" table="TREE">
<id
column="TREE_ID"
name="Id"
type="integer"
>
<generator class="sequence" >
<param name="sequence">SEQ</param>
</generator>
</id>

<set name="Leafs" inverse="true" lazy="true" cascade="all" >
<key column="TREE_ID"/>
<one-to-many class="Leaf"/>
</set>

</class>
</hibernate-mapping>


<hibernate-mapping package="de.hybernate">
<class name="Leaf" table="LEAF">
<id
column="LEAF_ID"
name="Id"
type="integer"
>
<generator class="sequence" >
<param name="sequence">SEQ</param>
</generator>
</id>

<property
column="TREE_ID"
length="15"
name="TreeId"
not-null="true"
type="integer"
/>
<many-to-one class="Tree" name="TREE" column="TREE_ID" not-null="true" insert="false" update="false"/>
</class>
</hibernate-mapping>




tx = session.beginTransaction();
Tree tree =new Tree();
stammdepot.add(leaf);
session.save(tree);
session.flush();
tx.commit();

public class Stammdepot extends BaseStammdepot {


public Stammdepot () {
super();
}

/**
* Constructor for primary key
*/
public Stammdepot (java.lang.Integer id) {
super(id);
}

/**
* Constructor for required fields
*/
public Stammdepot (
java.lang.Integer id,
java.util.Date updatedatum,
java.lang.Integer updateId,
java.lang.Integer datenschutzklausel) {

super (
id,
updatedatum,
updateId,
datenschutzklausel);
}

/*[CONSTRUCTOR MARKER END]*/
public void add (Leaf leaf) {

leaf.setTREE(this);
this.addLeaf(leaf);


}


}


org.hibernate.PropertyValueException: not-null property references a null or transient value: de.hybernate.Leaf.TreeId
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 11:28 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
What does this.addLeaf do? Can you post the code for that, and the complete stack trace for the exception?


Top
 Profile  
 
 Post subject: Re: Mapping Bidirektional one-to-many cascade Problem
PostPosted: Mon Apr 25, 2005 11:43 am 
Newbie

Joined: Mon Apr 25, 2005 9:32 am
Posts: 2
siad wrote:
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.01
I try this mapping but when I use the cascade Option I get an Exeception. Can anybody help me ?
Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="de.hybernate">
<class name="Tree" table="TREE">
<id
column="TREE_ID"
name="Id"
type="integer"
>
<generator class="sequence" >
<param name="sequence">SEQ</param>
</generator>
</id>

<set name="Leafs" inverse="true" lazy="true" cascade="all" >
<key column="TREE_ID"/>
<one-to-many class="Leaf"/>
</set>

</class>
</hibernate-mapping>


<hibernate-mapping package="de.hybernate">
<class name="Leaf" table="LEAF">
<id
column="LEAF_ID"
name="Id"
type="integer"
>
<generator class="sequence" >
<param name="sequence">SEQ</param>
</generator>
</id>

<property
column="TREE_ID"
length="15"
name="TreeId"
not-null="true"
type="integer"
/>
<many-to-one class="Tree" name="TREE" column="TREE_ID" not-null="true" insert="false" update="false"/>
</class>
</hibernate-mapping>




tx = session.beginTransaction();
Tree tree =new Tree();
stammdepot.add(leaf);
session.save(tree);
session.flush();
tx.commit();

public class Tree {


public Tree () {
super();
}

/**
* Constructor for primary key
*/
public Tree (java.lang.Integer id) {
super(id);
}

/**
* Constructor for required fields
*/


public void add (Leaf leaf) {

leaf.setTREE(this);
this.addLeaf(leaf);


}


}


org.hibernate.PropertyValueException: not-null property references a null or transient value: de.hybernate.Leaf.TreeId
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)


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.