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

一直报错:The constructor Student(int, String, String, Date, String) is undefined

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.junit.After;

import org.junit.Before;


public class StudentTest {

private SessionFactory sessionFactory;

private Session session;

private Transaction transaction;


@Before

public void init() {

Configuration config = new Configuration().configure();

ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties())

.buildServiceRegistry();

sessionFactory = config.buildSessionFactory(serviceRegistry);

session = sessionFactory.openSession();

transaction = session.beginTransaction();


}


@After

public void destroy() {

transaction.commit();

session.close();

sessionFactory.close();

}


public void testSaveStudent() {

Student s = new Student(1, "张三丰", "男", new Date(), "武当山");

session.save(s);

}

}


正在回答

2 回答

Student的带参构造函数没写吧,或者参数顺序写的不对吧,检查一下~

0 回复 有任何疑惑可以回复我~

student构造函数是不是没有重写

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

一直报错:The constructor Student(int, String, String, Date, String) is undefined

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信