spring + hibernate3.0.5 的批量删除解决方案

阅读更多
public class HibernateDaoSupportCash extends HibernateDaoSupport{

/** 基于HQL的批量删除 */
public boolean zteHqlDelete(String hqlDelete){
boolean r = false;
Session session = getSession();
Transaction t = session.beginTransaction();
try{
session.createQuery( hqlDelete ).executeUpdate(); r = true;
t.commit();
session.close();
}catch(Exception e){
t.commit();
session.close();
System.out.println("批量删除异常:");
e.printStackTrace();
}
return r;
}

public static void main(String[] arg){
    ApplicationContext context = new ClassPathXmlApplicationContext("HibernateContext.xml");

    }


}

你可能感兴趣的:(Spring,XML)