Using Hibernate 3.2
Hi,
When I load a serialized version of a detached object and attempt to update it in another session I always get the following error:
java.lang.NullPointerException
at org.hibernate.type.IntegerType.next(IntegerType.java:59)
at org.hibernate.engine.Versioning.increment(Versioning.java:108)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:358)
at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:250)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)....et etc etc
I can see from looking at the entity that it has a null version but shouldnt hibernate check the version number in the DB if it is null...?
The serialized object definetly has the same ID as the persisted object in the DB.
The psuedo code for what Im doing looks like:
// Load serialized object
// create new session
// create new transaction
// Call session.update(object)
// FLush session
// Commit transaction
// Close Session
----------------------------------
The config for this object looks like.....
<class entity-name="base.Identifiable" abstract="true" lazy="false" discriminator-value="base.Identifiable" table="`base_identifiable`">
<meta attribute="eclassName">Identifiable</meta>
<meta attribute="epackage">http://www.sdmx.org/resources/infomodel/1.0/base.xmi</meta>
<id name="urn" type="java.lang.String">
<column not-null="true" unique="false" name="`urn`"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler">
<meta attribute="syntheticVersion">true</meta>
</version>
<list name="Annotation" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`annotable_annotation_e_id`" not-null="false" unique="false"/>
</key>
<list-index column="`annotable_annotation_idx`"/>
<one-to-many entity-name="base.Annotation"/>
</list>
<property name="id" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`id`"/>
</property>
<property name="uri" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`uri`"/>
</property>
<many-to-one name="Name" entity-name="base.InternationalString" cascade="all" lazy="false" insert="true" update="true" not-null="false">
<column not-null="false" unique="false" name="`internationalstring_name_e_id`"/>
</many-to-one>
<many-to-one name="Description" entity-name="base.InternationalString" cascade="all" lazy="false" insert="true" update="true" not-null="false">
<column not-null="false" unique="false" name="`internationalstring_description_e_id`"/>
</many-to-one>
</class>
Anyone any ideas....I thought Hibernate could handle reattaching detached objects.
cheers
Duncan
|