Null foreign key results in Transient Object Exception
------------------------------------------------------
Key: HHH-2612
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2612
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Environment: Hibernate version 3.2 cr3, Oracle 8i
Reporter: maxtor
Priority: Blocker
Two tables A and B where B is parent table and the relation between A and B is
unidirectional many-to-one.
mapping for A:
<hibernate-mapping package="parms">
<class name="A" table="A" lazy="true"
batch-size="20" select-before-update='true' >
<id name="id" column="ID">
<generator class="increment"/>
</id>
<many-to-one name="b" column="Ba_ID" class="B"
not-found="ignore" cascade="none" lazy="false"
not-null="false" unique="false" />
<property name="place" column="PLACE"/>
</class>
mapping for B:
<class name="B" table="B" lazy="true"
batch-size="10" select-before-update="true">
<cache usage="read-write"/>
<id name="id" column="B_ID" >
<generator class="assigned"/>
</id>
<property name="programId" column="GROUP_ID"
unique="true"/>
</class>
Also some of rows of table A have null values for column Ba_ID.
Now retrieval of these rows which have null values for column Ba_ID works fine. And it
retrieves a null relationship between the tables for these rows. Now when I try to update
column PLACE. It tries to update column Ba_ID also and there it throws a
TransientOBjectException.
But nothing is being changed for that column. Also cascade is set to "none".
Transaction scope code
A a=_form.getA(id);
a.setPlace("place");
sess.saveOrUpdate(a);
tx.commit();
sess.close();
And the last SQL statement being tried to be executed is:
UPDATE A set ......(all columns )..... where ID =?
And the exception thrown is:
[ERROR] AbstractFlushingEventListener - -Could not synchronize database state with session
<org.hibernate.TransientObjectException: B>
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira