Hi all
I have tested if the transaction is working properly when there are more than one program access the DB. The following simple program generate 10000 keys and I run another program that also generate 10000 keys.
Code:
for (int i = 0; i < 10000; i++) {
t = sess.beginTransaction();
KeyTable k = (KeyTable) sess.load(KeyTable.class, new Integer(1));
k.setNextKey(k.getNextKey() + 1);
t.commit();
}
The second program uses direct SQL to generate the key -
"update keytable set nextkey = nextkey + 1 where keyId = 1"
However, when the program finishes the nextkey value only increased by 18554 and there was about 1500 keys missing.
I have run Two second programs at the same time, then no key is missing. So, it is should not be the problem in the DB.
Does anyone know how to do this? Please Help!