openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Serialization between ehanced and non-enhanced objects
Date Thu, 28 Jun 2007 07:36:46 GMT
Hi,

It sounds like our proxy list wrappers are not exernalizing themselves
properly in your environment. What version of OpenJPA are you using?
Also, can you post your class file itself so that we can take a closer
look at it? Also, can you post your OpenJPA configuration settings?

-Patrick

On 6/27/07, Jere McDevitt <jeremcd349@alltel.net> wrote:
> The documentation makes the following claim:
>
>
>
>
> 2.4.  Serializing Enhanced Types
>
>
> By default, OpenJPA maintains serialization compatibility between the
> enhanced and unenhanced versions of a class. This allows you to serialize
> instances between a server using OpenJPA and a client that does not have
> access to enhanced classes or OpenJPA libraries. In some cases, however, you
> can make the persist and attach processes more robust and efficient by
> allowing breaks in serialization compatibility. See Section
> <http://openjpa.apache.org/docs/openjpa-0.9.0-incubating/manual/manual.html#
> ref_guide_detach_graph>  1.3, " Defining the Detached Object Graph " for
> details.
>
>
>
> However, in actual practice I have not been able to make this work.  When I
> have a class structure like:
>
>
>
> @Entity
>
> public class User {
>
>
>
>             @Id
>
>             private String userId;
>
>
>
>             @Column(nullable=false)
>
>             private String password;
>
>
>
>             @ManyToMany
>
>             @JoinTable(name="UserRoles",
>
>                         joinColumn=@JoinColumn(name="userId",
> refererencedColumName="userId"),
>
>                         inverseJoinColumns=@JoinColumn(name="rolename",
> referencedColumnName="roleName"))
>
>             List<Role>  roles;
>
>
>
> }
>
>
>
> @Entity
>
> public class Role {
>
>
>
>             @Id
>
>             private String roleName;
>
>
>
> }
>
>
>
> and I enhance these classes, the enhancer adds into the User.class file an
> additional object of type org.apache.openjpa.util.java$util$ArrayList$proxy
>
> which actually wrapps the 'roles' field.  Additionally, all of the actual
> field attributes are encapsulated inside another object called 'default'.  I
> can't seem to serialize in any manner that will work,  either with
> ObjectOutputStream, java.beans.XMLEncoder or XStream.toXML,
>
>
>
> When an attempt is made to deserialize in another JVM that does not have the
> enhanced classes, and does not have the openjpa package at all, it fails.
> Straight ObjectOutputStream fails with class not found for the above
> ArrayList$proxy, XMLCoder generates NullPointerExceptions because it can't
> find the class, and XMLStream doesn't recognized either the class or the
> 'default' tag that was generated on the server side.
>
>
>
> I tried adding in the
>
>
>
> @DetachedState private Object state
>
>
>
> but that doesn't seem to do anything but add an additional field that gets
> filled with a byte array.
>
>
>
>
>
> The XML that is provided by java.beans.XMLEncode which shows the location of
> the proxy object is:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <java version="1.6.0" class="java.beans.XMLDecoder">
>  <object class="commons.UserProfile">
>   <void property="emailAddress">
>    <string></string>
>   </void>
>   <void property="firstName">
>    <string>System</string>
>   </void>
>   <void property="lastName">
>    <string>Administrator</string>
>   </void>
>   <void property="password">
>    <string>d69ea425c1a1ad4043f915887f9cd562</string>
>   </void>
>   <void property="phoneNumber">
>    <string></string>
>   </void>
>   <void property="roles">
>    <object class="org.apache.openjpa.util.java$util$ArrayList$proxy">
>     <void method="add">
>      <object id="Role0" class="commons.Role">
>       <void property="roleName">
>        <string>player</string>
>       </void>
>      </object>
>     </void>
>     <void method="add">
>      <object id="Role1" class="commons.Role">
>       <void property="roleName">
>        <string>dungeonmaster</string>
>       </void>
>      </object>
>     </void>
>     <void method="add">
>      <object idref="Role0"/>
>     </void>
>     <void method="add">
>      <object idref="Role1"/>
>     </void>
>    </object>
>   </void>
>   <void property="userId">
>    <string>admin</string>
>   </void>
>  </object>
> </java>
>
>
> So how do you actually implement serialization from an enhanced server side
> object to a non-enhanced client side object?
>
>
>
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message