• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Transaction Question

 
Naidu Sanapala
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an entity EJB with container managed persistence. If I call the set methods on various fields, the database does an update each time. I can understand this from the way EJB's work. However I have an audit trail that is created based on an Oracle trigger. Each time there is update, the trigger fires. If I do 5 sets, I create 5 audit records which are just copies of the original record including the changes.

This is easy to fix with transactions. If I enclose all of the set calls in a transaction block in my servlet code calling the EJB, I only get one audit record. Really this is what I want any way since if a form posts multible values, I want all succeed or none.

However the problem is that when I do a get method to read values from the bean, the trigger fires also. I am not sure why this would be. The Oracle trigger is configured to fire on updates or inserts. This doesn't make sense to me. Why would a get of a value fire an update trigger?

Cheers,

Naidu Sanapala
Laurel, Maryland, USA.
..................................................................................................
Naidu Sanapala - JAVA ARCHITECT , Laurel , Maryland , USA
1.SUN Certified Enterprise Architect for J2EE Technology
2.Sun Certified [EJB] Business Component Developer for the J2EE Platform
3.Sun Certified Web Component Developer for the J2EE Platform
4.Sun Certified Java Programmer for the Java 2 Platform - 1.4
5.IBM Certified Solution Developer for XML and Related Technologies
....................................................................................................
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!