j2ee hibernate delete 删除多条记录
我有教师表字段有id、name、title主键是id,当然也有教师类,通过下面的方法可以删除id=1的那条记录,但如果我想删除title=none的那些记录呢???该怎么...
我有教师表字段有id、name、title主键是id,当然也有教师类,通过下面的方法可以删除id=1的那条记录,但如果我想删除title=none的那些记录呢???该怎么写???
@BeforeClass
public static void beforeClass(){
sf = new AnnotationConfiguration().configure().buildSessionFactory();
}
@Test
public void testDelete2() {
Teacher t = new Teacher();
t.setId(1);
Session session2 = sf.getCurrentSession();
session2.beginTransaction();
session2.delete(t);
session2.getTransaction().commit();
}
@AfterClass
public static void afterClass(){
sf.close();
} 展开
@BeforeClass
public static void beforeClass(){
sf = new AnnotationConfiguration().configure().buildSessionFactory();
}
@Test
public void testDelete2() {
Teacher t = new Teacher();
t.setId(1);
Session session2 = sf.getCurrentSession();
session2.beginTransaction();
session2.delete(t);
session2.getTransaction().commit();
}
@AfterClass
public static void afterClass(){
sf.close();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询