• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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: 8944
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: 8944
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)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic