These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: settings for using 10.4.3 Application Version Checking
PostPosted: Mon Jun 14, 2004 8:58 pm 
Newbie

Joined: Tue Oct 14, 2003 2:07 pm
Posts: 10
Location: Berkeley, CA
Although I did not find explicit settings for using the strategy as mentioned in Hibernate usage doc 10.4.3 Application Version Checking, i.e. versions are maintained by Hibernate but application programmers have sole control over determining staleness, I'm assuming you need 2 things
1. class definition set with dynamic-update="true" optimistic-lock="none"
2. a version column.

Please correct me if I'm wrong. Also does anyone have a better pattern for implementing 2 different locking strategies on the same entity pending different circumstances. I.e. a record updated via an automated service such as EDI must always go through overwriting all changes, but a record update triggered by a end user must force requery on a stale update.



Sincere thanks to all responders.


Top
 Profile  
 
 Post subject: NullPointerException Using versioning + optimistic-lock=none
PostPosted: Wed Jun 16, 2004 6:48 pm 
Newbie

Joined: Tue Oct 14, 2003 2:07 pm
Posts: 10
Location: Berkeley, CA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.