• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Private methods in EJBs cannot have transaction attributes

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In CMT private methods never create a new transaction.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
agree with you.

that was a typo (supports does not create new tx)
 
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic