Hi GURUS.
I have base question.
There is 2 classes
Code:
<hibernate-mapping>
<class name="model.Classification" table="classification">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">test</param>
</generator>
</id>
<set name="ObjectRelation_test" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="id_object1"/>
<one-to-many class="model.ObjectRelation_test" />
</set>
</class>
</hibernate-mapping>
and
<hibernate-mapping>
<class name="model.ObjectRelation_test" table="object_relations" where="code_object1=1 and code_object2=1">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">test</param>
</generator>
</id>
<property name="code_object1" not-null="true"/>
<property name="role"/>
</class>
</hibernate-mapping>
And there is:
Code:
Classification cls=(Classification)session.load(Classification.class,new Long(1));
Set mySet=cls.getObjectRelation_test();
ObjectRelation_test obr=new ObjectRelation_test();
obr.setRole(new Long(22));
mySet.add(obr);
So tell me how to set automaticly value ot
Code:
code_object1
in
Code:
ObjectRelation_test
to be equal of
Code:
Classification.id
In this moment when create commit, there is
Code:
Cannot insert a null into column (object_relations.id_object1)