[jboss-user] [EJB/JBoss] - Problem with updating same row several times in one transact

wonker do-not-reply at jboss.com
Mon Aug 21 12:50:09 EDT 2006


I am a relative newbie to JBoss so excuse my dumbness or the lack of technical info, but heres my best shot. I am using ejbs (generated via xdoclet) and JBoss 3.2.5.

In my facade methods, I can potentially update the same db row several times in one transaction i.e.


  | for(Iterator it = updates.iterator()l; it.hasNext();) {
  | 
  |     // Get value object
  |     TestValue value = (TestValue) it.next();
  | 
  |     // Get local home instance
  |    TestLocalHome home = (TestLocalHome) homeFactory.getLocalHome(TEST_LOCAL_HOME);
  | 
  |     // Get local instance
  |    TestLocal local = home.findByPrimaryKey(value.getId());
  | 
  |     // Update local instance
  |     local.setCommissionFeeValue(value);
  |     
  |     // Print some debug
  |     System.err.println("Updating - " + local.getCommissionFeeValue());
  | }
  | 

In sql terms it would be like -


  | UPDATE TEST SET VALUE = 'A' WHERE ID = 1;
  | UPDATE TEST SET VALUE = 'B' WHERE ID = 1;
  | UPDATE TEST SET VALUE = 'C' WHERE ID = 1;
  | UPDATE TEST SET VALUE = 'D' WHERE ID = 1;
  | ...
  | 

Although for some reason, JBoss only issues an UPDATE sql command to the db, only after the last update (I know this through the logs as only then does the EJBQL command get dumped to the logs).

The reason this is a problem, is that I have a trigger on the table which after these updates writes into an audit table, recording all chanes to the row. So for the scernaio above I should see 4 audit rows, but I only see the 1 (corresponds to the last update).

Does anyone have ideas about if this is a coding issue or if JBoss is trying to be clever. Is there a way I can make it un-clever :)

Cheers,

Niraj

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966486#3966486

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966486



More information about the jboss-user mailing list