使用Hibernate自帶的工具hbm2ddl,建立根據你的對象建立數據庫:
首先建好POJO object, XML Mapping File(也可以使用工具根據POJO class建立),配置文件(hibernate.cfg.xml)
Java代碼
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class SchemaUtil {
public static void main(String[] args) {
Configuration cfg = new Configuration().configure();
SchemaExport schemaExport= new SchemaExport(cfg);
schemaExport.create(false, true);
}
}
posted on 2009-04-11 16:31
lanxin1020 閱讀(164)
評論(0) 編輯 收藏 所屬分類:
hibernate