Dear all,
I have problem with sesion.load(Test.class, new Integer(id)) with the native type of generator if Id is zero.
Previously, this has been working fine with "increment". the returned object is null.
But after I changed it to "native", the same code returns "something" as Test$$EnhancerByCGLIB$$xxx when I use debugger to step into it.
I can't access any of its value using system out print. Since it is not null, when .save(), i get following error:
org.hibernate.util.JDBCExceptionReporter (JDBCExceptionReporter.java:58) - Cannot add or update a child row: a foreign key constraint fails
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.test.Test#0]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.test.Test$$EnhancerByCGLIB$$fac28c5a.getIsTemplate(<generated>)
Apart from this, I starts to get LockAcquisitionException on and off.
<id name="id" column="`id`" type="integer" unsaved-value="0">
<generator class="native">
</generator>
</id>
lazy=true
in POJO, the data type for Id is "int"
Hibernate 3.0
MySQL 4.1 - jdbc connector 3.1.10
thank you in advance
|