hibernate4中SchemaExport新用法

用了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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章