openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject Re: Base entity class in separate jar
Date Fri, 17 Sep 2010 20:52:27 GMT
Donald,

I think I have solved my problems the following way:

- I do not list the base class in the persistence.xml. This is what caused
the problem when running the ant task on projects containing sub classes.
The ant task tried to enhance all the classes in the persistence.xml (the
default) and couldn't find the base class.
- I run the enhancer ant task on the project containing the base class. I
now specify exactly what class to enhance using the "<fileset>" tag in the
ant task to specify what class to enhance. That way I do not need a dummy
persistence.xml like I wrote before.

No outstanding problems presently. I still haven't got everything to work
with Aries but I'm getting there...slowly...

/Bengt

2010/9/17 Donald Woods <dwoods@apache.org>

> Some questions to get started -
>
> Which JDK are you using?  We have a dynamic enhancer that uses the
> Attach API in JDK6 or later.
>
> How is your application being packaged and what runtime environment are
> you using?
>
> For enhancing in Maven, you can try the openjpa-maven-plugin
>  http://openjpa.apache.org/enhancement-with-maven.html
> but use openjpa version 2.0.1 instead of 1.2.2 as on the wiki.
>
>
> -Donald
>
>
> On 9/17/10 3:13 AM, Bengt Rodehav wrote:
> > I'm using OpenJPA 2.0.1. All my entities share some common properties
> like:
> >
> > - createdBy
> > - createdWhen
> > - updatedBy
> > - updatedWhen
> > - version
> > - id
> >
> > I therefore create a superclass (EntityBase) that contains these
> properties.
> > It is an abstract class annotated with @MappedSuperclass. However, I'm
> not
> > sure how to handle this class. In runtime OpenJPA tries to find an
> enhanced
> > version but cannot find it.
> >
> > I list both the EntityBase class and the sub classes in the persistence
> > descriptor and I use
> >
> > <exclude-unlisted-classes>true</exclude-unlisted-classes>
> >
> >
> > It seems to be best-practice although I think it's really bad to maintain
> > the list of entity classes in a separate XML file like this. Would like
> to
> > be able to skip this in the future.
> >
> > During testing I have used
> >
> > <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
> >
> >
> > It's really convenient but OpenJPA cannot find the EntityBase class. I
> > therefore try to use compile time enhancing instead using an ant task
> from
> > within maven (it would be really nice if OpenJPA provided a maven plugin
> for
> > this). First I did this in the maven project containing the sub classes
> but
> > the enhancer then complains that it cannot find the EntityBase class. I
> then
> > run the enhancer both in the maven project containing EntityBase and the
> > maven project containing the sub classes. It then turns out that the
> > enhancer cannot run without having a persistence descriptor, which my
> > framework project doesn't need. I then created a dummy descriptor just so
> I
> > could list the EntityBase class but still can't get it to work.
> >
> > Without getting even more into the details I was hoping that maybe
> someone
> > else has encountered the same problem and can suggest a solution to the
> > following problem: How can entities in OpenJPA use a common base class
> that
> > is built separately and located in a separate jar?
> >
> > /Bengt
> >
> >
> >
> >
> >
> > It need to be in a separate jar than the sub classes since it will be
> shared
> > by many different entities. It's a typical framework class. If I use
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message