EJB and Hibernate app in Struts

I have an application that has a combination of struts 1.1 and EJB 2, but now we are introducing a new part to it with hibernate 3.2. A sleeping DAO starts in parallel with an EJB 2 bean DAO session with pure JDBC. In this case, I am worried about jdbc connection management. Because EJB 2.0 has container-managed connections and transactions. But in the case of sleep mode, we start and complete a hibernation transaction. Would it be safe to assume that there would be no problems with this architecture.

You need help with the analysis.

PM


I considered the same problem if the hibernation module can access existing tables used by the JDBC DAO whose transaction is being controlled by a Beans session. But here is my approach:

  • I will have a delegate that calls the EJB bean session, and since this bean will be responsible for transaction management, I will create my hibernate DAO and call them from this bean session, which I assume there will be no problems.

  • The hibernate factory session for this application will be created once using the hibernate plugin, which will be part of the struts xml configuration file and saved as part of the servlet context, and then the action class will pass this sessionfactory from the EJB bean to the DAO for hibernation.

  • I assume this will be a clean approach, as the transaction will be controlled by the EJB beans that are deployed to the web page. Managing JDBC connection pools, as configured on a web page and accessible by data sources, hibernation need not worry about this.

, , ?

+3
3

, , . , . EJB2 + JDBC, ?

0

- CMT ( BMT) beans, JDBC .

11.2. , , 11.2.2. JTA.

, Hibernate "" , JDBC. API, :

  • JDBC (, ).
  • Hibernate concurrency JDBC
  • Hibernate API ( ), .
0

Here is one possible solution.

A common JNDI data source that will be used in both EJB and Hibernate.

0
source

Source: https://habr.com/ru/post/1773882/


All Articles