hibernate快速新建数据表 方便测试

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yhld456/article/details/52563896

hibernate快速新建数据表 方便测试

package com.test;


import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;

import com.pojo.Score;
import com.util.HibernateUtil;

public class HibernateTest {
    @Test
    public void testCreateDB(){
        Configuration cfg=new Configuration().configure();
        SchemaExport se=new SchemaExport(cfg);
        /**
         * 第一个参数是否生成ddl脚本
         * 第二个参数是否执行到数据库
         */
        se.create(true,true);
    }
}

猜你喜欢

转载自blog.csdn.net/yhld456/article/details/52563896