您的位置:首页 > 其它

hibernate 5.0中如何使用SchemaExport

2015-08-30 22:25 239 查看
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)已经失效,所以再要使用的话 就得按下面的方式来执行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: