how to make sure that hibernate committed a transaction?
I've got a very weird behavior, in my java (spring) application, I've a case where i save an object using hibernateTemplate, then calling a thread which try to get this object again using hibernateTemplate, if am running in debug mode every thing is working fine, but when am not, it most of time give me null pointer exception, as the object returned back from the second call in the thread returns a null object,
so bottom-line here is: i think hibernate didn't commit its transaction, before the thread is started,
so how to make sure that the object is saved i DB before the thread starts,
R开发者_如何学Goegards,
Executing a flush() should do the job.
so bottom-line here is: I think hibernate didn't commit its transaction, before the thread is started
Why would Hibernate do that? Actually, Hibernate doesn't provide automatic transaction handling.
so how to make sure that the object is saved i DB before the thread starts,
Commit the transaction started in Thread #1 before starting the new Thread #2.
Without more details about your Spring/Hibernate setup and the transaction handling, it will be hard to get a more detailed answer IMO.
精彩评论