When defining an entity to use versioning with application level control (as described in 10.4.3) with setting
dynamic-update="true" optimistic-lock="none", a simple update causes a NullPointerException during an entity update.
We are on hibernate 2.1.4, mysql-3.23
# mapping document
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<meta attribute="JavaClassPrefix">LockExample</meta>
<meta attribute="extends">com.xxxxxxx.framework.persistence.HibernatingEntity</meta>
<class name="com.navis.sandbox.business.SimpleFoo" table="sandbox_simplefoo"
dynamic-update="true" optimistic-lock="none" >
<id name="sfooGkey" column="sfoo_gkey" type="java.lang.Long" length="10" unsaved-value="null">
<generator class="native"/>
</id>
< version name="sfooVersion" column="sfoo_version" type="long"/>
<property name="sfooName" column="sfoo_name" type="string" length="64" unique="true"/>
</class>
</hibernate-mapping>
# the full stack trace of any exception that occurs
Code:
java.lang.NullPointerException
at net.sf.hibernate.impl.BatchingBatcher.addToBatch(BatchingBatcher.java:30)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:689)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2368)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.xxxxxxx.sandbox.persistence.ConcurrentSfooUpdateSaTestSuite.testSimpleFooUpdate(ConcurrentSfooUpdateSaTestSuite.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
### Code snippet from my Junit test
Code:
Session session = SessionFactoryUtils.getSession(this.getSessionFactory(), false);
if (session != null) {
try {
SimpleFoo foo = (SimpleFoo) session.load(SimpleFoo.class, fooGkey);
logger.info("Foo version = " + foo.getSfooVersion());
foo.setSfooName(new Long(System.currentTimeMillis()).toString());
session.flush();
} catch (HibernateException ex) {
fail();
}
Any clarifying answers will be appreciated. My coworker could not find a JUnittest in the Hibernate cvs repository which covers
dynamic-update="true" optimistic-lock="none" case. If I don't get answers, I will probably post on Jira.
Thanks,
Hster