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

Private methods in EJBs cannot have transaction attributes  RSS feed

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I hear that private methods in EJBs cannot have transaction attributes.
Can someone spellout the reason why?

Regards,
Saj
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would a client call a private method?
 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Private methods cannot be called by client directly. But they can be called indirectly.. i.e a public method calling the private method.
However still by original questions goes unanswered
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private. It is not visable to a client, so why declare any extra attributes? All you would be doing is effectively subverting the declaration for which ever public method calls your private method.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Private methods execute in the same context as the public methods which access them.
 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradip,
So if a public method "parent" has a attribute of "Requires New", would the private method suspend the "parent" transaction and start its own.

and if the same private method is called from a "parent2" with attribute of "Mandatory", the private method will "Join" the transaction?


I thought private methods behaved like the "supports" attribute, ie. If there is a existing transaction, they join it. If there is no transaction, they do create a new transaction.

Now I am not sure,
Please comment...
Avi
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In CMT private methods never create a new transaction.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Avianu Sud:
So if a public method "parent" has a attribute of "Requires New", would the private method suspend the "parent" transaction and start its own.



As mentioned by Paul private methods do not start a new transaction so in the above case private method execute in the same Tx context as the public method. The Tx is not suspended.


and if the same private method is called from a "parent2" with attribute of "Mandatory", the private method will "Join" the transaction?


Same here.


I thought private methods behaved like the "supports" attribute, ie. If there is a existing transaction, they join it. If there is no transaction, they do create a new transaction.


You could say that private method has "support" Tx attribute but "supports" does not create transaction as you have mentioned above.
 
Avianu Sud
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
agree with you.

that was a typo (supports does not create new tx)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!