-->
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.  [ 3 posts ] 
Author Message
 Post subject: Detached entity errors
PostPosted: Tue Dec 09, 2008 3:57 pm 
Newbie

Joined: Fri Nov 21, 2008 3:35 pm
Posts: 12
I'm using Hibernate on an application server to work with AMF serialized data types. What this means is that the client (AS3/Flash Player) declares classes and the way that they are serialized (eg. writeObject() writeUTF() etc.) and the server that runs Hibernate takes these objects and deserializes them, mapping them to Java classes specified by the client. The client specifies this alias via an AS3 method call "registerClassAlias("path.of.my.JavaClass", ClientClass);". When the server receives an object, it finds the corresponding alias for it as specified by the client, and deserializes its fields to an instance of that Java class. The server I am using already handles all of this for me, so it's no big deal to use.

The workflow is this. Client connects to server. Client issues a RMI call to the server, which uses Hibernate to fetch whatever objects the client desires. Server returns those values to the client, serializing them into AMF so the client can read them as native values. The client performs some changes on them and sends them back to the server via a RMI call telling the server to update them. They are deserialized and recognized as regular Java objects, and then they are passed to Hibernate for updating/persisting/deleting, etc.

However, I have experienced some problems when using Hibernate with these objects. They are annotated POJO's, so Hibernate shouldn't see them as anything different than the Java objects that they are, right? I mean, I can work with them like native Java objects, because they are native Java objects with values injected on deserialization of the AMF types.

Anyway, I often receive the following errors. I often get a TransientStateException when calling "session.update(value)", which tells me the object I passed is transient/detached and I should try calling an operation on it before I flush the session. The same thing sometimes occurs after calling "persist." I have also experienced quite a few problems with using collections, though I am absolutely certain that the collections are serialized correctly; however, there are alternative ways of updating/persisting/deleting objects in a collection than the current way I'm doing it (which is done all by cascading). The main workaround I have found to these errors is creating a proxy object for each object I wish to perform persistence operations on, essentially loading the instance with a given "id" from the database, then applying the changes in the newer object to the older one from the db, then session.update()'ing it. This is obviously a messy workaround.

I guess what I'm asking is, how can I get around this? Is there a way I can explicitly attach an instance to a session and perform all of these operations without fault? Can anyone help me out with this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 4:10 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Yes, but I guess you don't want to start from scratch (and the users of this group probably won't) so it would be nice if you could provide some of the code, mappings, stack traces, etc. that you have right now.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2008 4:22 pm 
Newbie

Joined: Fri Nov 21, 2008 3:35 pm
Posts: 12
Nordborg,
I will set up an example project that demonstrates some of the errors I am experiencing and post it after I've got it together.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.