hibernate 5.x版本中中schemaexport的使用

public static void main(String[] args) {
/*//创建hibernate配置对象 Configuration cfg = new Configuration(); //指定hibernate.cfg.xml的位置.一般指默认位置不用指定。如果换了就必须指定。 cfg.configure("hibernate.cfg.xml");*/

ServiceRegistry sr = new StandardServiceRegistryBuilder().configure().build(); MetadataImplementor mi = (MetadataImplementor) new MetadataSources(sr).buildMetadata(); //创建Schema,表的对象.目的是根据数据生成表 SchemaExport se = new SchemaExport(); se.create(EnumSet.of(TargetType.DATABASE), mi); }

 

posted @ 2019-05-21 11:15  永远没对象  阅读(467)  评论(0编辑  收藏  举报