I have to use some JPA features and I want to serialize entity bean
till the client entity beans and hibernate collections. (I know that
i can't use JPA services on the client and I know that i can't access
lazy properties).. I cannot use anything like hibernate4gwt or Gilead
because my Application Server (JBoss) is incompatible (it use the JPA
EntityManager instead HibernateEntityManager). I solved the problem of
the JPA annotations using a jpa-annotation library. The remaining
problem is to provide serialization for hibernate collections, in
particular of PersistentMap. I built a module with the code of this
collection:
package org.hibernate.collection;
import java.util.HashMap;
import java.util.Map;
public class PersistentMap extends HashMap {
public PersistentMap() {
super();
}
public PersistentMap(Map map)
{
super(map);
}
}
and a Custom field serializer for this class:
package org.hibernate.collection;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
import java.util.List;
import java.util.Iterator;
/**
* Custom field serializer for {...@link
org.hibernate.collection.PersistentMap}.
*/
public class PersistentMap_CustomFieldSerializer {
public static void deserialize(SerializationStreamReader
streamReader, org.hibernate.collection.PersistentMap
instance)
throws SerializationException
{
int size = streamReader.readInt();
for(int i=0; i<size; i++)
{
Object key =
streamReader.readObject();
Object value =
streamReader.readObject();
instance.put(key, value);
}
}
public static void serialize(SerializationStreamWriter
streamWriter,
org.hibernate.collection.PersistentMap instance)
throws
SerializationException
{
int size = instance.size();
streamWriter.writeInt(size);
Iterator iter =
instance.keySet().iterator();
while(iter.hasNext())
{
Object key = iter.next();
streamWriter.writeObject(key);
Object value =
instance.get(key);
streamWriter.writeObject(value);
}
}
}
I put them in the same folder.. is there a problem?
When I compile there is no problem. I try to execute the client, that
retrieve from the server an object containing a Map field, where I
assign an empty PersistentMap istance. The call fails, but no error
message is displayed. When I execute in hosted mode, I get the error
message:
IncompatibleRemoteServiceException: This application is out of date,
please refresh...
If i put a HashMap instead of a PersistentMap all works, and nothing
is out of date!
Where is the problem?!!?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---