您的位置:首页 > 其它

Hibernate 使用SchemaExport自动生成表

2017-11-06 16:15 211 查看

在Hibernate5.x版本中,SchemaExport构造方法发生变化。

之前的使用方法如下:

  SchemaExport export = new SchemaExport(new Configuration().configure());

export.create(true,true);

现在,自动生成表的用法如下:

        ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();

        Metadata metadata = new MetadataSources(serviceRegistry).buildMetadata();

        SchemaExport schemaExport = new SchemaExport();

        schemaExport.create(EnumSet.of(TargetType.DATABASE), metadata);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: