📄 basehibernatedao.java
字号:
package com.jadebird.hk.hibernate.dao.base;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import com.jadebird.hk.hibernate.vo.ProjectInfo;
public class BaseHibernateDAO {
static Configuration config=new Configuration();
static SessionFactory sf=null;
static {
config.addClass(ProjectInfo.class);
sf=config.buildSessionFactory();
}
public Session getSession(){
return sf.openSession();
}
/**
* 创建表
*/
public static void main(String[] args) {
SchemaExport sc=new SchemaExport(config);
sc.create(true, true);
System.out.println("create table ok");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -