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)