我在 MyEclipse IDE 中编写了这个休眠程序。我想从学生表中检索数据并在控制台中显示,我想检索主键值为 2 的行(正如我在数据库中的表中输入的那样)我得到以下异常:线程“主”org.hibernate.MappingException中的异常:未知实体:java.lang.Integer
程序:
package info.inetsolv;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class HibJavaPrgm {
public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure();
SessionFactory sf = cfg.buildSessionFactory();
Session hsession = sf.openSession();
Transaction ts = hsession.beginTransaction();
Student stu=new Student();
hsession.load(2,stu);
ts.commit();
hsession.close();
sf.close();
}
}