Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TransactionAttributeType.NEVER in Remote Interface

 
Mustafa Garhi
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I read that NEVER can be useful when you do not want developers to write Database critical code in a method, so that if they do that an exception would result. So while trying to practice that at home, i tried to decorate my interface method declaration with attribute @TransactionAttribute(TransactionAttributeType.NEVER) but no exceptions were thrown when i call the Session Bean without already having a transaction. Surprisingly, when i decorated the Session Bean's method (as opposed to the method declaration in interface) itself with @TransactionAttribute(TransactionAttributeType.NEVER), the same call results in an Exception. I am using jboss 5. What went wrong here? Can i not use @TransactionAttribute(TransactionAttributeType.NEVER) in the Remote Interface itself?

Thanks
Asif
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the EJB3.0 spec (section 13.3.7.1):

A transaction attribute may be specified on a method of the bean class to override the transaction attribute value explicitly or implicitly specified on the bean class.


So the transaction attribute is expected to be specified on the bean implementation class and not the interface(s).



 
H Paul
Ranch Hand
Posts: 471
4
 
Mustafa Garhi
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.

I don't know how easy it is to go through any specs but i definitely need to learn that.

Closing this issue.

Cheers
Mustafa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic