为了账号安全,请及时绑定邮箱和手机立即绑定

我的测试显示绿色,数据库里没有信息

我的测试显示绿色,数据库里没有信息

jiayy 2016-07-23 20:24:24
package entity;import java.util.Date;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry;import org.hibernate.service.ServiceRegistryBuilder;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 = config.buildSessionFactory(serviceRegistry);         Session session = sessionFactory.getCurrentSession();    SchemaExport export = new SchemaExport(config);    export.create(true,true);     }     @Test     public void testSaveStudents(){    Configuration config = new Configuration().configure();    ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();         SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry);         Session session = sessionFactory.getCurrentSession();         Transaction tx = session.beginTransaction();                  Students s1 = new Students("S0000001","张三丰","男",new Date(),"武当山");         Students s2 = new Students("S0000002","郭靖","男",new Date(),"桃花岛");         Students s3 = new Students("S0000003","黄蓉","女",new Date(),"桃花岛");                  session.save(s1);         session.save(s2);         session.save(s3);                  tx.commit();         sessionFactory.close();          }}
查看完整描述

1 回答

?
jiayy

TA贡献12条经验 获得超3个赞

明白了,点下三角在testSaveStudent()点junit

查看完整回答
反对 回复 2016-07-23
  • 1 回答
  • 0 关注
  • 1381 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信