I would like introduce JavaEEUtils
In my JPA projects, I often started with doing the same things:
Create some basic JPA entity classes that all others extend. With last project I moved them into a separate project which I called JavaEE utils.
They include the following base classes:
A superclass for all persistent entities. Defines a Log id, a version field and a createdBy/At combination.
To be used for entites that not only have the tecnical key from PersistentEntity, but also a functional key.
Used when Lists of these entites are merged in DB.
Defines updatedAt/By combination.
Additionally I took the idea from an Adam Bien presentation and this post and created a mechanism to use the EntityManager inside entity beans
- In your StatelessSessionBean use the EnableEntityManagerInterceptor interceptor.
- When you know need an EntityManager inside your domain objects, just call EntityManagerHelper.get().
The code can be found at http://code.google.com/p/javaeeutils/
Tell me what you think about it…