(%%%%%)struts+hibernate+oracle9i在删除程序中删除不了记录,请问是那的错(@@@@@@)
以下这样写对吗?
我的StudentDAOImp.java是这样写的
----------------------------------
public boolean deleteStudentByID(String id) {
// TODO Auto-generated method stub
try {
Session s = HibernateUtil.currentSession();
HibernateUtil.beginTransaction();
Userlist stu = (Userlist) s.load(Userlist.class, new Long(id));
HibernateUtil.commitTransaction();
System.out.println(stu.getId());
HibernateUtil.beginTransaction();
s.delete(stu);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
return true;
} catch (
HibernateException e) {
log.fatal(e);
}
return false;
}
HibernateUtil.java如下
----------------------------
public static void beginTransaction() {
System.out.println( "begin tx ");
Transaction tx = (Transaction) threadLocal.get();
try {
if (tx == null) {
tx = currentSession().beginTransaction();
threadLocal.set(tx);//tLocaltx
}
} catch (HibernateException e) {
// throw new InfrastructureException(e);
}
}
public static void commitTransaction() {
Transaction tx = (Transaction) threadLocal.get();
try {
if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack())
tx.commit();
threadLocal.set(null);//tLocaltx
System.out.println( "commit tx ");
} catch (HibernateException e) {
// throw new InfrastructureException(e);
}
}
我的DeleteStudent.java是这样写的
---------------------------
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = (String)request.getParameter( "student_id ");
System.out.println( "iddddd= "+id);
stuDao = this.getStudentDAO();
if(!stuDao.deleteStudentByID(id