Session 界别

Session 区分1.?????? What’s the difference between SessionFactory.getCurrentSession() and SessionFa

Session 区分

1.?????? What’s the difference between SessionFactory.getCurrentSession() and SessionFactory.opeSession();

If get current session is null, session factory will create a new session replace of current session.

Current session will be close automatically after session get transaction commit.

Open session is always a new session was created.

2.?????? Hibernate transation implements in JDBC

JDBC?????????????????????????????????????????????????????????????????????

Hibernate

Connector.setAutoCommit(false)

session.beginTransaction();

Connector.commit()

session.getTransaction().commit()

Connector.setAutoCommit(true)

???????????????????????????????????????????????