在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);