Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uncommitted transaction state

 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem I am getting is that in a single transaction, if there are suppose 4 insert statements fired, and in next sequence select query is fired on same table then that select returns only 3 records and not 4 (total uncommitted records) which is wrong, it does not return the last inserted record to select query. But while committing it saves all 4 records.
What will be the problem why select gets only 3 records instead of 4?
We are using EJB 2.1
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no way to tell from this description. You'd have to show us code and/or log files to debug this.
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The transaction is like this:
In a first class it calls mstHome.create(..,..,..,....) method to insert a record in a table for say 4 times in loop.
This successfully creates records. Still data is not committed.
Then the next class in chain fires JDBC select statement on the same table to get newly entered ids- which returns only 3 records instead of 4.
Finally while committing, 4 records gets committed.

I am bit confused about the behavior of transaction as if there are 3 inserts, select returns 2 records and so.
As the project is large & complex, I'll not be able to post exact code here. And there are no errors in between transaction processing.

Thanks in advance,
Deepa
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is starting to get a little clearer -- your example helped. What verison of WAS are you using and what Database (and driver) are you using?
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using the WAS version 6.0 and database is DB2 using JDBC driver type 4 - "DB2 UDB" and jars used are :
db2jcc.jar, db2jcc_license_cu.jar, db2java.zip.

Thanks
Deepa
[ August 18, 2008: Message edited by: Deepa More ]
 
Deepa More
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem solved.
It needs some flushing to be done for cached data.
So I called one finder method after insertion of records. Now it returns all records properly.

Thanks again.
Deepa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic