• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transaction Attribute

 
karandikartushar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the important of transaction attribute in EJB
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very important, especially if you spend hours debugging why something doesn't work, and you discover your deploy tool has magically switched your EJB business method from "required" to "not supported".

Besides all the other stuff that comes along with transactions, there is a critical container-provided service that transactional business methods are given. If you business method is transactional, then the container calls ejbLoad immediately before the transaction, and ejbStore immediately after.

The advantage of this is simplicity in your business methods. As a crude example:
If this was a business method that you send a boolean value, and it 'expires' the current Entry, how would this change get pushed back to the database? where is the code to do it? answer: in ejbStore... which gets called right after this transactional business method. I don't have to write the database storage code in each method. BTW: this is all assuming you are using BMP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!