Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

EJB Transaction Question

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
....................................................................................................
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic