package entity;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
public class TestStudent {
@Test
public void testSchemaExport(){
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ).buildMetadata();
new SchemaExport(metadata).create(true, true);
}
}由于在Hibernate5.0中SchemExport(Configuration)已经失效,所以再要使用的话 就得按下面的方式来执行了。
本文介绍Hibernate5.0中如何使用SchemaExport工具类来创建数据库表结构,因为该版本中SchemaExport构造函数已不再支持Configuration参数。
3648

被折叠的 条评论
为什么被折叠?



