hibernateutil.java
来自「hibernate入门代码适合初学者使用」· Java 代码 · 共 24 行
JAVA
24 行
package com.bluedot.commons;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static SessionFactory sf;
static {
if (sf == null) {
Configuration cfg = new Configuration().configure();
sf = cfg.buildSessionFactory();
}
}
public static SessionFactory getSessionFactory() {
return sf;
}
public static Session getSession() {
return sf.openSession();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?