🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 绑定 hibernate 提供了此方法,不用自己去手写了. 特点: 1. 默认关闭,需要配置开启 . ~~~ <property name="hibernate.current_session_context_class">thread</property> //开启,从当前线程中获取session ~~~ 2. 会自动关闭连接. ## 代码 ~~~ SessionFactory sessionFactory = Hibernate.getSessionFactory(); Session currentSession = sessionFactory.getCurrentSession(); Transaction tx = currentSession.beginTransaction(); //TODO tx.commit(); ~~~