[seam-issues] [JBoss JIRA] Updated: (JBSEAM-2389) HibernatePersistenceProvider fails with java.lang.Integer version check
Marek Novotny (JIRA)
jira-events at lists.jboss.org
Fri Jun 3 07:20:59 EDT 2011
[ https://issues.jboss.org/browse/JBSEAM-2389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marek Novotny updated JBSEAM-2389:
----------------------------------
Workaround Description: Use primitive for version field in entity or initialize it to '0'
Workaround: [Workaround Exists]
> HibernatePersistenceProvider fails with java.lang.Integer version check
> -----------------------------------------------------------------------
>
> Key: JBSEAM-2389
> URL: https://issues.jboss.org/browse/JBSEAM-2389
> Project: Seam 2
> Issue Type: Bug
> Components: Core
> Reporter: Christian Bauer
> Priority: Critical
> Fix For: The future
>
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list