Configuration、SessionFactory、Session

原作者: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获得 Sessioninstances 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

 
Interface Transaction

 

 


猜你喜欢

转载自tian19870221075.iteye.com/blog/2072644
今日推荐