Hi,
sorry. Just realised I´ve postet to wrong forum. Here is the english translation of my message.
ninan wrote:
Hi,
I see very strange behaviour with Hibernate. I run some Hibernate Code within synchronized block. I will show it using pseudocode:
foo();
synchronize(this) {
beginTransaction();
readData();
deleteTheReadData();
flush();
clearSession();
commitTransaction();
}
If there are two threads the second thread is blocked on reaching synchronize(this). If the first thread leaves the synchronized area, second thread continues.
Now readData() returns the very SAME objecs (even same position on heap) the first thread deleted in its run. Running deleteTheReadData() throws an exception as one might expect.
If I set a breakpoint at foo(), start two threads and continue execution of first thread till it finishes and run thread two afterwards everything works fine.
Second level caches are inactive. I can only imagine there is some problem with the first level cache. The Session is saved in ThreadLocal.
Does anybody has a clue what is going on here?
Best regards
Christian Kalkhoff