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.  [ 1 post ] 
Author Message
 Post subject: NullPointer on version increment when reattaching object
PostPosted: Fri Jun 15, 2007 11:45 am 
Newbie

Joined: Fri Jun 15, 2007 6:25 am
Posts: 2
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


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

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.