I have a large legacy system that uses hibernate in a somewhat unconventional way.
Basically, one thread hangs on to a connection taken from the hibernate session and performs batch jdbc inserts into a table. (I won't get into why this happens but just that it was due to performance considerations). Another thread uses hibernate's SQLQuery object to retrieve data from that same table.
So here's what seems to happen - thread 1 writes the data to the table - I confirm the data is in the table by doing a select from a separate db client - thread 2 tries to read that data and sees nothing even though the data is there
I tried one other thing which was - I manually insert the data to the table from my db client - thread 2 tries to read that data and returns successfully
The problem is probably related to the writing thread's use of hibernate. While the connection is committed, perhaps the hibernate session should be have a beginTransaction and transaction.commit as well?
Thoughts?
|