cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Hollow Objects after sending them via JMS
Date Mon, 26 Nov 2007 12:10:31 GMT
Hi Detlef,

I guess the easiest way to handle this is to restore default Java  
serialization behavior, overriding CayenneDataObject context based  
deserialization. E.g. you may use the following class as a customer  
superclass of all your entity classes:

public class SerializableDO extends CayenneDataObject {

	private void writeObject(ObjectOutputStream out) throws IOException {

	private void readObject(ObjectInputStream in) throws IOException,
			ClassNotFoundException {

		this.values = (Map) in.readObject();
		this.objectId = (ObjectId) in.readObject();
		this.persistenceState = PersistenceState.TRANSIENT;


On Nov 22, 2007, at 11:49 AM, Detlef Burt wrote:

> Hello List,
> as you might expect, i got a small problem.
> The scenario is the following:
> I have a framework that communicates completely via OpenJMS. It has  
> a "PersistenceLayer" that can be configured to use different  
> PersistenceFrameworks. One of these is Cayenne.
> The Program flow is the following:
> 1. Send a request to the server (in my Testcase: "get Extents of  
> Class X from Database")
> 2. The PersistenceLayer handles the request and returns the correct  
> results from the Database in a Vector --> Up to this point,  
> everything is fine
> 3. Send the Vector back to the Application that requested the Data.
> Now this is where my Problem is:
> I get a Vector with the right amount of Entries and they all have  
> the right class, but all the Objects are hollow and return null for  
> every property/class field.
> I found out, that I can keep the Objects contents when I call  
> DataContext.unregisterObjects, but after reading some more posts on  
> this group, I do remember reading something about unregisterObjects  
> not being  a good solution. Quoting Andrus:
> "In any event I would advise against using "unregisterObjects",  
> unless you are sure there are no remaining cached objects that point  
> to unregistered objects via a relationship."
> So my question is:
> Is there a more elegant solution to my problem? I really would like  
> to keep all the Data from the Objects and maybe even the ObjectId of  
> the Objects to be able to more easily reference the Objects in the  
> Database.
> Thanks in Advance,
> Detlef

View raw message