openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject Base entity class in separate jar
Date Fri, 17 Sep 2010 07:13:40 GMT
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