aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes transaction in session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "transaction in session bean" Watch "transaction in session bean" New topic
Author

transaction in session bean

vianyrajnish rajnish
Ranch Hand

Joined: Apr 22, 2007
Posts: 70
hi,

i want to know do i need to maintain transaction in Session Bean or Hibernate

if my project is having this architechture in order.


jsp , action servlet , request processor , action , business delegate, session bean, dao , hibernate components, then database .


1..which one is better ?
2..or it is mandratory to maintain in session bean ?

thanks,

vinay rajnish
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30955
    
158

Vinay,
I would think the session bean is better because it is at a higher level. This allows all the database calls to be in the same transaction. If that is your desired behavior, the session bean transactions gives this to you easily.

The session bean is not required to have a transaction though. You can use "never" as the value.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vianyrajnish rajnish
Ranch Hand

Joined: Apr 22, 2007
Posts: 70
hi ,


But hibernate too has the transaction maintainence capability ....


then which one to use....


first of all I want to know why the session beans are used ....we can directly access hibernate components from th Action , BD , DAO.

please help me ....confused

Regards,
vinay rajnish
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Hibernate supports JDBC, JTA and container-managed transactions. You need to decide which is best for your application. Coming from the EJB world, I have to admit to being biased in favour of CMT session beans.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30955
    
158

Vinay,
Session beans do more than just transactions. They also handle security (among other things.) Also, using the session bean for the transaction layer makes it easier to change the back end data access technology in the future because you transaction is at the facade level. Again, this assumes you WANT a transaction at the facade level.

As Roger pointed out, it depends on your specific application. On apps I have worked on, the session bean level was almost always the right level for the transaction.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transaction in session bean