hibernate - . , openSession (Connection):
Connection conn = ... // get from jndi
Session session = sessionFactory.openSession(connection);
try{
//do some work with either hte connection or the session or both
}finally{
session.close();
conn.close();
}
, , , , , , hibernate jdbc-.
EDIT: @ChssPly76 , , hibernate , JTA . JTA, hibernate, jdbc- jdbc, , hibernate , jdbc, - factory. , Hibernate:
Connection conn = ... // get from jndi
Session session = sessionFactory.openSession(connection);
try{
Transaction tx = new Transaction(); //
//do some work with either hte connection or the session or both
tx.commit();
}finally{
session.close();
conn.close();
}
.