Hello,

The following article gives the basic idea:
http://famvdploeg.com/blog/2008/08/blazeds-and-hibernate-proxied-objects/

In my case, I used a custom Map implementation, called ExternalMap, that is
used to transfer map data over BlazeDS (so that I can map it to my custom
HashCollection on the client side).
In the HibernatePropertyProxy mentioned in the article, I simply overrode
the following method:

@Override
  public Object getInstanceToSerialize(Object instance) {
    // TODO Auto-generated method stub
    Object instanceToSerialize = null;
    if (instance instanceof Map) {
      instanceToSerialize = new ExternalMap();
      PersistentMap map = (PersistentMap)instance;
      for (Object key : map.keySet()) {
        ((Map)instanceToSerialize).put(key, map.get(key));
      }
    }
    else {
      instanceToSerialize = super.getInstanceToSerialize(instance);
    }
    return instanceToSerialize;
  }


Hope this may be useful.

Regards,
-- 
Sébastien




2010/5/10 Sébastien Tromp <[email protected]>

> Hello,
>
> I am using Flex and the client side, Java + Hibernate on the server, and
> BlazeDS to communicate between them.
> One typical scenario I am facing is:
> - Create a new bean in the Java code, and persist it using Hibernate's
> getTemplate().save(myObject)
> - Send this object to the client using BlazeDS.
>
> However, if "myObject" has a Map attribute, Hibernate populates it with a
> PersistentMap, thus sending it to the client.
> Is there a way I could use to _not_ send PersistentMaps, but rather
> standard HashMaps?
>
> Thank you for your help,
> --
> Sébastien Tromp
>

Reply via email to