Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 91115 invoked from network); 28 Jun 2007 02:26:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jun 2007 02:26:11 -0000 Received: (qmail 20460 invoked by uid 500); 28 Jun 2007 02:26:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 20418 invoked by uid 500); 28 Jun 2007 02:26:14 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 20399 invoked by uid 99); 28 Jun 2007 02:26:13 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2007 19:26:13 -0700 X-ASF-Spam-Status: No, hits=2.3 required=10.0 tests=HTML_FONT_BIG,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of jeremcd349@alltel.net designates 166.102.165.170 as permitted sender) Received: from [166.102.165.170] (HELO ispmxmta09-srv.windstream.net) (166.102.165.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jun 2007 19:26:09 -0700 Received: from ispmxaamta08-gx.windstream.net ([71.28.31.149]) by ispmxmta09-srv.windstream.net with ESMTP id <20070628022548.LYOV3155.ispmxmta09-srv.windstream.net@ispmxaamta08-gx.windstream.net> for ; Wed, 27 Jun 2007 21:25:48 -0500 Received: from greymouse ([71.28.31.149]) by ispmxaamta08-gx.windstream.net with ESMTP id <20070628022547.TZYP4980.ispmxaamta08-gx.windstream.net@greymouse> for ; Wed, 27 Jun 2007 21:25:47 -0500 Reply-To: From: "Jere McDevitt" To: Subject: Serialization between ehanced and non-enhanced objects Date: Wed, 27 Jun 2007 22:25:47 -0400 Message-ID: <000f01c7b92b$a34a8250$0401a8c0@greymouse> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0010_01C7B90A.1C38E250" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: Ace5K6L+Q9pynVXjRLeRMPluoDDywg== X-Virus-Checked: Checked by ClamAV on apache.org ------=_NextPart_000_0010_01C7B90A.1C38E250 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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 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: System Administrator d69ea425c1a1ad4043f915887f9cd562 player dungeonmaster admin So how do you actually implement serialization from an enhanced server side object to a non-enhanced client side object? ------=_NextPart_000_0010_01C7B90A.1C38E250--