SleepyBear wrote:
session.load(id) will throw an exception if the object can't be found in the DB. Use load() only when you are certain that the object will be found. get() will return a null if the object cannot be found. Use get if you are not absolutely certain that the object is there.
i know about above:
see the follows code:
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
System.out.println("session : isConnected:" + session.isConnected());
System.out.println("session : isOpen:" + session.isOpen());
tx.commit();
System.out.println("session : isConnected:" + session.isConnected());
System.out.println("session : isOpen:" + session.isOpen());
the result is:
session : isConnected:true
session : isOpen:true
session : isConnected:
false
session : isOpen:true
i want to know why when i call tx.commit() ,and then the session is disconnected