-->
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: SAVING Status
PostPosted: Thu Nov 03, 2005 9:28 pm 
Beginner
Beginner

Joined: Tue Aug 03, 2004 1:13 pm
Posts: 23
Hibernate version: 2.1.8
FlushMode = on commit

Im trying to trace down an issue im having with deserializing the session.
The code is greatly simplified but produces the same sequence as the production code.

I do the following :

Code:
 
// Session is already open

// A is a mapped object
S.saveOrUpdate( new A() );

// verify the session is dirty
assert( S.isDirty() );

// disconnect the session ( as we cant serialize a connected session )
S.disconnect();

// Serialize the session
Object state = doSerialize( S );

// Deserialize the session
S = (Session)doDeserialize( state );


I get a deserialization problem ( InvalidObjectException ) from net.sf.hibernate.impl.SessionImpl.Status. A status of "SAVING" was serialized out, but the readResovle doesnt allow that value to be read back in.

If i comment out the assert it works just fine (as no entity with state SAVING is serialized).

Is there some way to work around this?

Effectivly what i am doing is a long transaction by doing operations on a flush on commit session that is deserialized, modified based on the users input, disconnected and serialized into user state. IsDirty is used to determine if the user has made any changes (net of all the edits they have done. Ie changing a property then puting it back nets to no change). Then at some point the user indicates that they either want to discard all they have done or save it.


Top
 Profile  
 
 Post subject: Correction....
PostPosted: Thu Nov 03, 2005 10:21 pm 
Beginner
Beginner

Joined: Tue Aug 03, 2004 1:13 pm
Posts: 23
Correction ( accidentally ommited the second part of the code )

Code:
// Session is already open

// A is a mapped object
S.saveOrUpdate( new A() );

// verify the session is dirty
assert( S.isDirty() );

// disconnect the session ( as we cant serialize a connected session )
S.disconnect();

// Serialize the session
Object state = doSerialize( S );

// Deserialize the session
S = (Session)doDeserialize( state );

// reconnect the session
S.reconnect();
S.beginTransaction();

// locate the instance of a from the session
A a = (A)locateInstance( A.class, S )

B b = new B();

a.getChildren().add( b );

// verify the session is dirty
assert( S.isDirty() );

// disconnect the session ( as we cant serialize a connected session )
S.disconnect();

// Serialize the session
Object state = doSerialize( S );

// Deserialize the session
S = (Session)doDeserialize( state );



A.children is a one-to-many list with cascade=all-delete-orphan

The exception occurs on the loading of the state for the instance of object B.

If I either:
a) comment out the second assert, or
b) add a call to S.saveOrUpdate( b ) the deserialize works correctly. (NOTE this is not viable to do in the appliation, but is mentioned inorder to diagnose the problem )

So it seems to be a problem with transient objects picked up by cascading.


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.