Hibernate version:2.1.7
Mapping documents:I am using a simple x-doclet M-1
<many-to-one
name="SLContact"
class="com.palantir.db.SLContact"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
access="field"
column="SL_Contact_ID"
not-null="true"
/>
If I run the code with not-null as false, then it works. (I changed the database to accomodate this test).
It issues two insert statements, and then an update - great, except the the database is now incorrect as I had to allow null values.
(@hibernate.many-to-one column="SL_Contact_ID" cascade="save-update" not-null="false")
If I mark the relationship as
not-null
(@hibernate.many-to-one column="SL_Contact_ID" cascade="save-update" not-null="true")
Then I get the exception.
I have attached the trace. The contact does get inserted,
the generated value is returned 653502.
The
generated value is not put into the insert statement for the SHStakeholder instance.
The cascades are done, but the cascaded key value is not transferred.
Code:
2004-11-25 10:40:00,520 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/HibernateFactory
2004-11-25 10:40:00,520 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=8ae496f7006edfbb01006ee2ea170001
2004-11-25 10:40:00,520 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2004-11-25 10:40:00,581 DEBUG [net.sf.hibernate.impl.SessionImpl] saving [com.palantir.db.SHStakeholder#<null>]
2004-11-25 10:40:00,581 DEBUG [net.sf.hibernate.impl.SessionImpl] executing insertions
2004-11-25 10:40:00,581 DEBUG [net.sf.hibernate.engine.Cascades] processing cascades for: com.palantir.db.SHStakeholder
2004-11-25 10:40:00,581 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
2004-11-25 10:40:00,581 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() unsaved instance
2004-11-25 10:40:00,681 DEBUG [net.sf.hibernate.impl.SessionImpl] generated identifier: 653502
2004-11-25 10:40:00,681 DEBUG [net.sf.hibernate.impl.SessionImpl] saving [com.palantir.db.SLContact#653502]
2004-11-25 10:40:00,681 DEBUG [net.sf.hibernate.engine.Cascades] done processing cascades for: com.palantir.db.SHStakeholder
2004-11-25 10:40:00,721 ERROR [STDERR] net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.palantir.db.SHStakeholder.SLContact