• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

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

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

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

使用道具 举报

发新帖

发布任务需求已有1031164位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!