package entity;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.*;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
public class TestStudents {
@Test
public void testSchemaExport()
{
//创建配置对象
Configuration config = new Configuration().configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
//创建sessionfactory
SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry);
//创建Session对象
Session session = (Session) sessionFactory.getCurrentSession();
//创建SchemExport
SchemaExport export = new SchemaExport(config);
export.create(true,true);
}
}