Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 93839 invoked from network); 13 Aug 2009 19:40:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Aug 2009 19:40:13 -0000 Received: (qmail 79071 invoked by uid 500); 13 Aug 2009 19:40:20 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 79009 invoked by uid 500); 13 Aug 2009 19:40:20 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Delivered-To: moderator for users@openjpa.apache.org Received: (qmail 71531 invoked by uid 99); 13 Aug 2009 19:32:15 -0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tglawles@us.ibm.com designates 32.97.182.139 as permitted sender) Subject: OpenJPA and JAXB X-KeepSent: 40443993:5F4DB1B8-85257611:00689CB4; type=4; name=$KeepSent To: users@openjpa.apache.org X-Mailer: Lotus Notes Release 8.5 HF58 February 06, 2009 Message-ID: From: Thomas G Lawless Date: Thu, 13 Aug 2009 15:30:30 -0400 X-MIMETrack: Serialize by Router on D01ML251/01/M/IBM(Release 8.0.1|February 07, 2008) at 08/13/2009 15:31:41 MIME-Version: 1.0 Content-type: multipart/alternative; Boundary="0__=0ABBFC82DFFB1A248f9e8a93df938690918c0ABBFC82DFFB1A24" Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org --0__=0ABBFC82DFFB1A248f9e8a93df938690918c0ABBFC82DFFB1A24 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: quoted-printable I have been experimenting with OpenJPA and JAXB with regard to storing = and retrieving XML from an DB2 9.7 database and I've run into a problem. I= 've gone through the steps of creating a simple XML schema and generating t= he Java classes using xjc. I have followed the steps in the OpenJPA manua= l so I have not defined a name space in the schema and I have added the @XmlRootElement annotation to the generated root class. I have created= sample code that successfully creates an instance of my entity with the= JAXB property and I can persist the entity to the database. I can also= retrieve the entity from the database and the XML is unmarshalled successfully as long as I use a single instance of the EntityManager to= do both tasks. What I've found is if I use a separate instance on EntityManager to retrieve the entity, I receive an error along the line= of this: org.apache.openjpa.persistence.PersistenceException: javax.xml.bind.JAXBElement incompatible with..... This only happens if I use a instance of EntityManager that is differen= t then the instance used to persist the original record. For example, if= I do the following: EntityManagerFactory emFactory =3D ....... EntityManager em =3D emFactory............ em.getTransaction().begin();............ /*. Create the instance of the JAXB class and the entity. Populate both classes with data. Set the JAXB property of the entity class */ em.persist(.....); em.getTransaction().commit(); MyEntity entity =3D em.find(.......); The above code executes without error. I've checked the db record and = it is correct. I have also validated the XML in the db against the schema= used to generate the JAXB classes and there are no issues there either.= If I run another program that tries to retrieve the same entity as above..= .. i.e. EntityManagerFactory emFactory =3D ....... EntityManager em =3D emFactory........... MyEntity entity =3D em.find(.......);.... the exception noted above is thrown. I am currently using OpenJPA 1.2.= 1 and JAXB 2.0.5. I have also tried this with JAXB 2.1.12 and I receive = the same result. Am I doing something wrong? Could this be a bug in OpenJ= PA?= --0__=0ABBFC82DFFB1A248f9e8a93df938690918c0ABBFC82DFFB1A24--