Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 36070 invoked from network); 16 Dec 2007 18:34:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2007 18:34:55 -0000 Received: (qmail 16651 invoked by uid 500); 16 Dec 2007 18:34:44 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 16630 invoked by uid 500); 16 Dec 2007 18:34:44 -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 Received: (qmail 16621 invoked by uid 99); 16 Dec 2007 18:34:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Dec 2007 10:34:44 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of plinskey@gmail.com designates 64.233.178.240 as permitted sender) Received: from [64.233.178.240] (HELO hs-out-2122.google.com) (64.233.178.240) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Dec 2007 18:34:22 +0000 Received: by hs-out-2122.google.com with SMTP id x43so1834097hsb.9 for ; Sun, 16 Dec 2007 10:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=X+3cufaG3aX81Syf+rO1jTcum24KuX6zxmZBQNw71M0=; b=RJHSTJKVxYhe03Wef11Fl49jjdHrZ3vcbv3iNSntJ68/CAJyeMBL/p9PrR4PH1a+WJgtXOVfD5lruzUzfrV1XebP+6piyk4ahLu/RCRYo8EOTAmlJvY3MNYrXnni+GXO6uZbtcvW9j1NAF7evsADY7b+5TdPHfrj73JiKBsq1mw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rxNpkFJoIzI7dH70VzeBqA3Gp7npdTQdKYM600IORxRprAj16J6MhFovh8WHVKPmYUtGZLptioIL11wROfhjuUmD4jpwgvbc4l02ZwHrVKBxIZ4aawinQqaljybZ5ijcDJvyfw3n519dvUvLGjopqeeNQiUy11JHI8RPAfHB/3I= Received: by 10.150.143.14 with SMTP id q14mr1993739ybd.44.1197830065709; Sun, 16 Dec 2007 10:34:25 -0800 (PST) Received: by 10.150.158.20 with HTTP; Sun, 16 Dec 2007 10:34:25 -0800 (PST) Message-ID: <7262f25e0712161034o4d5be983ha01185d7747e3fa@mail.gmail.com> Date: Mon, 17 Dec 2007 02:34:25 +0800 From: "Patrick Linskey" To: users@openjpa.apache.org Subject: Re: problem enhancing embeddable class In-Reply-To: <41c8480f0712160800i12c58476mc4ffa6a9cafb7e9f@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <41c8480f0712160800i12c58476mc4ffa6a9cafb7e9f@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org > it's in the spec, but anyway my question is: is there a way to avoid > listing every class in persistence.xml? or, instead, a way to indicate > the package? i feel it's kind of like going against "don't repeat > yourself", considering all these classes are already annotated. You can tell OpenJPA to look around for persistent classes like so: This will tell OpenJPA to scan the build and entities.jar classpath elements for entities, mapped superclasses, and embedded types. This is documented briefly at http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_meta_factory -Patrick On Dec 17, 2007 12:00 AM, francisco treacy wrote: > hi, > > i migrated my application from hibernate jpa to openjpa a couple of > weeks ago, and except for an issue with sublists the integration was > seamless. > > i later changed my DI framework (spring to guice) and in some of those > changes i started having "Could not locate metadata for the class > using alias... " errors. it was then that i found out i had to list > all my entities in persistence.xml. > i don't get why it didn't happen before, or with hibernate. i know > it's in the spec, but anyway my question is: is there a way to avoid > listing every class in persistence.xml? or, instead, a way to indicate > the package? i feel it's kind of like going against "don't repeat > yourself", considering all these classes are already annotated. > > but my real problem comes when i want to create (ddd) value objects. > these don't have identity and as such, should be "embedded" to > entities. i followed this post > http://debasishg.blogspot.com/2007/09/domain-modeling-with-jpa-gotchas-part-2.html. > > for instance, my Doctor entity has an Address. i'm using the > @Embeddable annotation in the Address class and @Entity in Doctor, > which has an @Embedded Address attribute. > > if i don't put test.domain.Address in the > persistence.xml file, i get a > > org.apache.openjpa.persistence.ArgumentException: One or more of the > types in [(here lots classes...)] have relations to other unenhanced > types that were not specified. These unspecified types are: [class > test.domain.Address] > > if i do, i get a > java.lang.NullPointerException > at org.apache.openjpa.enhance.PCEnhancer.fromBackingFieldName(PCEnhancer.java:3680) > at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:858) > at org.apache.openjpa.enhance.PCEnhancer.replaceAndValidateFieldAccess(PCEnhancer.java:807) > (...) > > it should work like that, since enhancement is optional. but i decided > trying to enhance all entities by executing the ant task (and not > listing Address in persistence.xml), i get a > > org.apache.openjpa.persistence.ArgumentException: The type "class > test.domain.Address" has not been enhanced. > > if i do list it, while executing the ant task i get a > [java] Exception in thread "main" nonfatal general error> org.apache.openjpa.util.GeneralException: An > error occurred while enhancing test.domain.Address. Exception message: > null > [java] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:470) > [java] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4349) > > > any ideas? what am i doing wrong? > > thanks in advance! > > francisco > -- Patrick Linskey 202 669 5907