0

Our Application uses a BMP ejb 2.1 entity bean . All database interactions are through plain JDBC and transactions. commit / roll back are handled at the session bean that invokes the 2.1 entity bean. We plan to remove the entity bean layer as it is no longer supported by the Java EE containers. This is acheived by converting the entity bean to POJO DAO layer and removing the bean defnition from ejb-jar.xml. resource-ref are defined for all the entity beans.
Is it sufficient to ensure that if the session bean calling the 2.1 entity bean has the same resource-ref defined?
can i remove the entity bean definition along with the resource reference and continue to use as a POJO DAO layer ?

I have tried the same approach of removing the entity definition along with the resource reference and validate the DB commits are working fine. Wanted to check if i have missed to consider any use case.

    <enterprise-beans>
       <entity>
          <display-name>EmployeeBean</display-name>
          <ejb-name>EmployeeBean</ejb-name>
          <local-home>employee.EmployeeHome</local-home>
          <local>employee.Employee</local>
          <ejb-class>employee.EmployeeBean</ejb-class>
          <persistence-type>Bean</persistence-type>
          <prim-key-class>employee.EmployeePK</prim-key-class>
          <reentrant>False</reentrant>
          <resource-ref>
                <res-ref-name>jdbc/OracleDS</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
          </resource-ref>
       </entity>
    </enterprise-beans>

Employee Bean i am converting from EJB to POJO and removing the entity definition from ejb-jar.xml . Will the Database interaction still work with out the resource-ref and will it participate in the JTA transaction if the calling session bean has defined the same resource reference?

vignesh787
  • 199
  • 1
  • 7
  • Given that you are using plain jdbc, it means that you are not using JTA in the first place, so no - the db operations will not participate in the jta transaction. – Svetlin Zarev Jun 10 '19 at 15:37
  • @svetlin the jdbc queries are invoked via bean managed entity beans(BMP) which are invoked from container managed session bean . Do they still not participate in JTA ? – vignesh787 Jun 10 '19 at 16:34
  • The DataSource that you are looking up will have its connections associated with the current JTA transaction (because this is mandated by the EJB specification). If you migrate your BMP bean to a DAO/POJO model then you would presumably implement the DAO as a session bean which will still need a resource-ref to allow the JNDI lookup to work in a platform independent way. – Steve C Jun 12 '19 at 14:49
  • Hi Steve, Thanks for your response. I would like to understand the issue if the DAO is implemented as POJO rather than as a session bean – vignesh787 Jun 13 '19 at 14:52

0 Answers0