Thanks for the answer pb00067.
Yes, the transaction is committed, and the session closed (the one which generated the insert).
Lets say, as an example, that the code is something like this:
Code:
// This operation does the insert, opening a new session, creating the object,
// saving, and committing. After that, the id generated for the object, is sent to
// the next method.
long id = createNewObject(data);
// This method publishes a task in a ThreadPool, but when the thread that gets the task,
// tries to access the object inserted, by 'id', its not there.
publishTask(id);
The strange thing is that sometimes it works, and sometimes not. If I put a sleep() between the two operations, lets say of 500 ms, it works ok, so apparently is like there is a delay AFTER the commit for the data to become 'visible'.
Any other ideas?