原作者:http://www.verydemo.com/demo_c146_i21781.html
Class Configuration
buildSessionFactory
SessionFactorySessionFactoryConfigurationSessionFactory
Interface SessionFactory
The main contract here is the creation of Session
instances. Usually an application应用 has a single SessionFactory
instance and threads servicing client requests obtain获得 Session
instances from this factory.
....................................................................
Implementors must be threadsafe.
Interface Session
typical典型的
Session sess = factory.openSession(); Transaction tx; try { tx = sess.beginTransaction(); //do some work ... tx.commit(); } catch (Exception e) { if (tx!=null) tx.rollback(); throw e; } finally { sess.close(); }
Session