Hi,
This is the code for the disconnectSession() at HibernateUtil in the latest CaveatEmptor example.
Code:
public static Session disconnectSession()
throws InfrastructureException {
Session session = getSession();
try {
threadSession.set(null);
if (session.isConnected() && session.isOpen())
session.disconnect();
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
return session;
}
My question is, instead of threadSession.set(null), shouldn´t be
Code:
try {
if (session.isConnected() && session.isOpen())
{
session.disconnect();
threadSession.set(session);
}
} catch ...
Because if it is threadSession.set(null), when we call the getSession, it will open a new session.
I don´t know if I missed something, but it is what I understood when you sugested the disconect() for the Long session at the Hibernate in action...
Thank you in advance
Pedro Henrique