问答详情
源自:3-6 [Hibernate单表操作] 单表操作CRUD实例

出错,为什么我只有Get方法可以运行?其他三个方法都报错

@Test

public void testGetStudents(){

Students s = (Students) session.get(Students.class, 1);

System.out.println(s.getClass().getName());

}

public void testLoadStudents(){

Students s = (Students) session.load(Students.class, 1);

System.out.println(s);

}

public void testUpdateStudents(){

Students s = (Students) session.get(Students.class, 1);

s.setGender("女");

session.update(s);

}

public void testDeleteStudents(){

Students s = (Students) session.get(Students.class, 1);

session.delete(s);

}


提问者:talent85012016 2016-12-15 18:39

个回答

  • 慕粉3796571
    2017-06-13 21:47:42

    添加注解@Test试一下

  • Yaro
    2017-02-09 21:37:55

    报错截图上来啊

  • 慕标0097473
    2016-12-16 17:50:23

    你有没有设置主外键关联啊?