openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Woods <>
Subject Re: How to unenhance entities ?
Date Wed, 17 Mar 2010 12:35:24 GMT
Which version of Geronimo or OpenJPA are you using?
The latest releases of Geronimo (2.1.4 or 2.2) uses OpenJPA 1.2.1 or
1.2.2 respectively, so I'll base my questions/answers on those for now.

For OpenJPA 1.2.x, the proper way to remove those $proxy classes for
serialization is to use the EntityManager.detach() or detachAll()
methods.  Both of these will return a copy of the given entity class
that has been detached and the $proxy classes removed.

We currently have JIRA issue OPENJPA-1097 open for the
EntityManager.clear() case, where the $proxy classes were still being
included after serialization.  The code changes that have gone into the
1.3.x and 2.0.0 trunk branches will now always remove these $proxy class
wrappers when a detachable entity is serialized.  This code has not been
backported to 1.2.x yet, as we don't want to introduce default
behavioral changes in maintenance releases.

To see the expected behavior of the $proxy classes being removed, take a
look in the source at following, which shows/tests each method behavior -


On 3/17/10 8:04 AM, S├ębastien Ursini wrote:
> Hello,
> I'm having an issue trying to make reporting(FOP) with my EJB entities. When
> i remote call my EJB service in eclipse and i try to serialize(XStream) my
> entity from my eclipse Junit test i obtain the following xml result :
> <?xml version='1.0'
> encoding='utf-8'?><com.ubiteck.mobideal.reporting.ReportNode>
>   <company>
>     <id>3</id>
>     <code>Capital_paris</code>
>     <name>Capital </name>
>     <location>Paris</location>
>     <confirmationEmails>....</confirmationEmails>
>     <enabled>false</enabled>
>     <type>BROKER_CLIENT</type>
>     <language>FR</language>
>   </company>
>  ......
> but when i try the same source code in a Geronimo application server, i'm
> having the following result :
> <?xml version='1.0'
> encoding='utf-8'?><com.ubiteck.mobideal.reporting.ReportNode>
>   <company serialization="custom">
>     <>
>       <default>
>         <enabled>false</enabled>
>         <address serialization="custom">
>           <Address>
>             <default>
>               <id>3</id>
>             </default>
>           </Address>
>         </address>
>         <addresses class="$util$ArrayList$proxy"
> serialization="custom">
>           <unserializable-parents/>
>           <list>
>             <default>
>               <size>0</size>
>             </default>
>             <int>10</int>
>           </list>
>         </addresses>
>         <code>Capital_paris</code>
>         <confirmationEmails>....</confirmationEmails>
>         <id>3</id>
> ......
> It seems that the result depends on if i am in the same JVM or not.
> Entities returned within the container are enhanced with proxy. I tried to
> detach the entities without success.
> I would like to return simple POJO not enhanced. How can i do this ?
> Thanks in advance for your help

View raw message