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.

About Charlee Chitsuk

I've been working as a software developer since 1998. At the moment I focus on system integration including with SOA and Enterprise Security Solution.

Posted on June 24, 2010, in EJB and tagged . Bookmark the permalink. 2 Comments.

  1. 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

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: