Para la documentación, aquí:
http://www.hibernate.org/5.html
En cuanto a las excepciones, creo que todas heredan de HibernateException. O si no haz un capturar Exception (no subas hasta Throwable) y así te aseguras de pillar cualquier cosa y cerrar la transaccion siempre.
Lo mejor es encapsular todo el tratamiento en una clase y reutilizarlo por todo, asi no te olvidas nunca de tratar ese caso que luego hace que falle la cosa.
<S>
Yo uso algo tal que así:
Código:
// Get the session
Session theSession = null;
Transaction theTX = null;
try
{
theSession = factory.openSession();
theTX = theSession.beginTransaction();
boolean error = false;
try
{
// Ejecucion de las acciones con la sesion Hibernate
//...
//...
}
catch (Exception e)
{
error = true;
// Informar de error
}
if (error && theTX != null)
{
try
{
theTX.rollback();
}
catch (HibernateException he)
{
// Informar de error haciendo rollback
}
}
else if (theTX != null)
{
try
{
theTX.commit();
}
catch (HibernateException he)
{
// Informar de error haciendo commit
}
}
}
catch (HibernateException e)
{
// Informar de error obteniendo la sesion
}
finally
{
if (theSession != null)
{
try
{
theSession.close();
}
catch (HibernateException e)
{
// Informar de error cerrando la sesión
}
}
}