Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

EJB Transaction Question

 
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
....................................................................................................
 
He's giving us the slip! Quick! Grab this tiny ad!
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic