The EJB Session Bean for wrapping the JPA Entity
My expectation is generating the JPA Entity by using the NetBeans or other tools. It does not suppose to be modified by hand. If there is any changing at the database layer, I will regenerate it.
I decide to create a EJB Session Bean for wrapping the basic functions for integrating with the JPA Entity, The set of Create, Read, Update , Delete (CRUD) functions, especially the variety of finding function. I hope it may help to increase the transparent JPA Entity changing. I treat this session bean as an interface for any required integrating by the other through the JPA entity, as long as there is no interface changing, there is also no the client changing, too.
Furthermore, this session bean should be accessed locally, since the other should not know how to manage this JPA entity. The difficulty and complexity should be hidden by wrapping as a business services, note I will update about it later.
I create the interface by annotating it as @Local to ensure the local accessing. The good news is the session bean can be derived from any POJO. I also wrap the common activity to the abstract class which implements that interface. The wrapping session bean will be derived from this abstract class and it is annotated as @Stateless
Note:
@Local is an annotation for the interface and declaring it to be accessed locally.
@Stateless is annotation for the POJO and declaring it to be a stateless session bean.
Posted on June 24, 2010, in EJB and tagged EJB 3.1. Bookmark the permalink. 2 Comments.



Working with generic value objects and jpa is also shown by the implementation of the ImixsEntityService EJB. This service ejb is provided by the Imixs Workflow Project. It can be used to store objects independent from a specific Entity Bean. Also queries with JPQL are possible.
See: http://www.imixs.org/jee/examples/entityservice.html
@rsoika
Thank you very much for your mentioned to the very nice tools. That’s a very interesting. I’m enthusiastic to try it.