• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Private methods in EJBs cannot have transaction attributes

 
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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
Hibernate Eclipse IDE 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.
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • 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.
 
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
Hibernate Eclipse IDE 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: 8943
Firefox Browser Spring Java
  • 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)
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic