Hi, I´m failing in update a data.
I´m using
Hibernate version:2.1.7c .
I have a many-to-many relationship.
Here my
Mapping documents:
Client mapping
Code:
<hibernate-mapping>
<class
name="foo.Client"
table="CLIENT"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="codigo"
column="CLNT_CD_CLIENT"
type="java.lang.Integer"
>
<generator class="identity">
</generator>
</id>
<version
name="versionDate"
type="java.util.Calendar"
column="XXXX_DH_ALT"
access="property"
unsaved-value="undefined"
/>
<set
name="clientTelephone"
lazy="true"
inverse="true"
cascade="save-update"
sort="unsorted"
>
<key
column="CLNT_CD_CLIENT"
>
</key>
<one-to-many
class="foo.ClientTelephone"
/>
</set>
</class>
</hibernate-mapping>
Telephone mapping
Code:
<hibernate-mapping>
<class
name="bar.Telephone"
table="NUMERO_TELEFONE"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="code"
column="NRTL_CD_NUMERO_TELEFONE"
type="java.lang.Integer"
>
<generator class="identity">
</generator>
</id>
<version
name="versionDate"
type="java.util.Calendar"
column="XXXX_DH_ALT"
access="property"
unsaved-value="undefined"
/>
<set
name="clientTelephone"
lazy="true"
inverse="true"
cascade="none"
sort="unsorted"
>
<key
column="NRTL_TN_NUMERO"
>
</key>
<one-to-many
class="foo.ClientTelephone"
/>
</set>
</class>
</hibernate-mapping>
ClientTelephone mapping
Code:
<hibernate-mapping>
<class
name="foo.ClientTelephone"
table="CLIENT_TELEPHONE"
dynamic-update="true"
dynamic-insert="true"
>
<id
name="code"
column="CLTL_CD_CLIENT_TELEPHONE"
type="java.lang.Integer"
>
<generator class="identity">
</generator>
</id>
<version
name="versionDate"
type="java.util.Calendar"
column="XXXX_DH_ALT"
access="property"
unsaved-value="undefined"
/>
<many-to-one
name="client"
class="foo.Client"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="CLNT_CD_CLIENT"
/>
<many-to-one
name="telephone"
class="bar.Telephone"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="NRTL_CD_NUMERO_TELEFONE"
/>
</class>
</hibernate-mapping>
I´ve already tried to insert a new data and then tried to update it or retrieved an existing data and then tried to update it. But in this 2 cases,
i got
this full stack trace:Code:
java.lang.RuntimeException: net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: foo.Clientetelephone.versionDate
foo.HibernateUtil.commitTransaction(HibernateUtil.java:98)
foo.HibernateDAO.commitTransaction(HibernateDAO.java:131)
foo.HibernateDAO.update(HibernateDAO.java:63)
at foo.clientetelephone.test.HibernateClientetelephoneDAOTest.testUpdate(HibernateClientetelephoneDAOTest.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: foo.Clientetelephone.versionDate
at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1286)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2591)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2280)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
foo.HibernateUtil.commitTransaction(HibernateUtil.java:94)
... 16 more
Debuggin Hibernate, in the method
Code:
Versioning.increment()
it received the version with a not null value and a
Code:
net.sf.hibernate.type.CalendarType object
But
Code:
CalendarType.next()
returns always null.
How to solve this problem ?