-
1. Re: How to close an open session with ENVERS?
adamw May 27, 2011 2:25 PM (in response to shyenuganti)Hmm, which version of Envers and Hibernate are you using? I think Envers should open a temporary session.
Also, I'm not a Spring user, but is there a possibility to first commit the transaction, and then close the session?Adam
-
2. Re: How to close an open session with ENVERS?
shyenuganti May 27, 2011 3:34 PM (in response to adamw)Hibernate 3.5.5. I think ENVERS comes as part of the core in this version.
Here is what I am doing:
DAO Code:
-------------------------------------------------------
try{
session.openSession();
Object obj = session.get(...);
obj.set(...)
sesion.flush();
}catch{
...
} finally{
session.close();
}
---------------------------------------------------
If I close the session in the finally() block, ENVERS is not able to do the auditing. If I dont close it, it works fine !!
I am using just Hibernate. Not with Spring. I am using a data source with CMT.
How can I close the open session once I come out of the DAO ? Is there any way that I can tell ENVERS to close any oepn sessions once it finishes its tasks?
-
3. Re: How to close an open session with ENVERS?
shyenuganti May 31, 2011 10:22 AM (in response to adamw)Adam,
If Envers uses temporary session to create audit records, why does it complain if I close the session manually ??
-
4. Re: How to close an open session with ENVERS?
adamw Jun 2, 2011 6:26 AM (in response to shyenuganti)Please check with a newer version of Envers (3.6).
Adam
-
5. Re: How to close an open session with ENVERS?
adamw Jun 2, 2011 6:27 AM (in response to shyenuganti)Ah, and how are you managing trasactions?
Basically here you should do it inside the session scope, that is start a TX when you open the sesison and commit before you close it.
Adam