Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding understanding of EJB Container Managed Transaction Attributes  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

This question is regarding using of EJB Transaction Attributes (Container Managed).

For Example if Required Attribute is there , it says that :

If the client is not associated with a transaction context, the container AUTOMATICALLY STARTS a new transaction before delegating a method call to the enterprise Bean business method.

What does this mean , my question is how the servlet is associated with a Transaction ??


Means , I have used EJB's in my two projects , but we used to call Session Bean class from my servlet with out any Transation .

My question is how the servlet or a normal java class will be associated with a Transaction ?? (Does this mean JTA)

Please help me in understanding .

Thanks .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My question is how the servlet or a normal java class will be associated with a Transaction ?? (Does this mean JTA)

Yes, it does.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul . That was really usefull and as far as my knowledge is concerned we will go for JTA only concerned only when we are using multiple Resources (For example different DataBases ) .

So in normal projects JTA would not be applicable . correct me if i am wrong .

Please reply . Thanks in advance.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are wrong. JTA is nothing more than an API for transaction handling. You can use it with single or multiple transactional resources (transactions are not limited to databases). You you have more than one transactional resource that needs to participate in a single transaction you need JTA with "two phase commit" (google for it if you don;t know the term).
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul .

 
Eswara Venkata Dogga
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An EJB can be a client to another EJB. For Ex: EJB_A invokes a business method on EJB_B then EJB_A is a client of EJB_B. If EJB_A is associated with a transaction then EJB_B shares the same transaction context if EJB_B has "Required" transaction attribute set. EJB_B cannot use the traansaction of EJB_A when EJB_B's transaction attribute is "RequiresNew" or "NotSupported"
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eshwar , could you please tell me ,

If EJB_A is associated with a transaction


How can EJB_A will be associated with a transaction without using JTA ??
 
K Abhijit
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran V wrote:
My question is how the servlet or a normal java class will be associated with a Transaction ?? (Does this mean JTA)


JTA is J2EE API . Available to any Java component getting executing in J2EE Container -


Ravi Kiran V wrote:
How can EJB_A will be associated with a transaction without using JTA ??


technically we can have JDBC transactions in EJB methods...
But this transaction would not be considered while evaluating Transaction attributes conditions by EJB container .... (required / requiredNew etc ... )

let me know in case you have any specific question...
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks that was really useful .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!