hibernate4中SchemaExport新用法

来源:互联网 发布:淘宝上质量好的服装店 编辑:程序博客网 时间:2024/04/29 22:15

用了hibernate4以后SchemaExport的方法也改变了
原先是这样的:

new SchemaExport(new AnnotationConfiguration(). configure()). create(false, true);

hibernate4以后取消了AnnotationConfiguration(过时),而引入了ServiceRegistry。
所以现在是这样的:

 Configuration cfg = new Configuration().configure();        new SchemaExport(new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry(), cfg).create(false,            true);
0 0