WAS 8.5.5 CMP/BMP and Persistence DataSource

121 views Asked by At

i'm developing a Java EE application, Using Servlet, JSP, JPA, EJB. Since i already configured a datasource (Oracle 11g) in Websphere console, i wanted to know if i have to use CMP Entity bean in my code, or A simple stateless Session bean with a persistence.xml (using the JNDI of the datasource configured in WAS).

Thanks in advance

1

There are 1 answers

0
Tracy On BEST ANSWER

You do not have to use CMP Entity beans. JPA is the replacement for EJB Entity beans and should be the preferred technology (using the JNDI of the datasource configured in WAS). CMP/BMP Entity beans are now an optional part of Java EE and are not supported in WebSphere Liberty (though they continue to be supported in WebSphere traditional, even in v9.0).

Also, you are not required to even use a stateless Session bean with JPA (persistence.xml); you could use JPA directly from your servlet, though a stateless session can be a nice way to encapsulate the database access and provide transactional support.

Note that using both CMP Entity beans and JPA (persistence.xml) concurrently should be avoided. You would end up with two different technologies both attempting to access (and lock) the database rows, and would like encounter deadlocks and/or corruption.