[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-2389) HibernatePersistenceProvider fails with java.lang.Integer version check

Christian Bauer (JIRA) jira-events at lists.jboss.org
Mon Dec 17 08:43:43 EST 2007


HibernatePersistenceProvider fails with java.lang.Integer version check
-----------------------------------------------------------------------

                 Key: JBSEAM-2389
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2389
             Project: JBoss Seam
          Issue Type: Bug
          Components: Core
            Reporter: Christian Bauer
            Priority: Critical


My entity had a version property:

    @Version
    @Column(name = "OBJ_VERSION", nullable = false)
    protected Integer version;

In a very involved ajax reRender/conversation situation I sometimes got the following exception from HibernatePersistenceProvider:

   public static void checkVersion(Object value, Session session, Object oldVersion, Object version)
   {
      ClassMetadata classMetadata = getClassMetadata(value, session);
      VersionType versionType = (VersionType) classMetadata.getPropertyTypes()[ classMetadata.getVersionProperty() ];
      if ( !versionType.isEqual(oldVersion, version) )
      {
         throw new StaleStateException("current database version number does not match passivated version number");
      }
   }

This failed because oldVersion was 'null' and version was '0'. 

Hibernate returned '0' from ClassMetaData.getVersion(), it looks like it can't return null, from Javadoc: Get the version number (or timestamp) from the object's version property (or return null if not versioned).

We should do a null check before asking Hibernate.

Workaround: Use primitive for version field in entity or initialize it to '0'. 




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list