问:请问在java中使用hibernate在实体类中执行多次更新,当我只使用一个单一的***()方法时,我的代码运行良好并更新犯罪行为但是当我添加更多方法来更新时作为setGender()的实体类,它说"发生异常:无法执行JDBC批量更新"请需要辅助帮助
<%@page import="org.hibernate.Transaction"%>
<%@page import="org.hibernate.Session"%>
<%@page import="entity.Criminal"%>
<%@page import="hibdao.HibernateUtil"%>
<%
try{
String Name=request.getParameter("Name");
String Criminalid=request.getParameter("CriminalId");
if(Criminalid=="")throw new Exception("Please provide a Criminal Id.");
String Gender=request.getParameter("Gender");
String Height=request.getParameter("Height");
String Weight=request.getParameter("Weight");
String PStationId=request.getParameter("PStationId");
String CrimeLevel=request.getParameter("CrimeLevel");
String Status=request.getParameter("Status");
/* out.println("id="+Criminalid);
out.println("name="+Name);
out.println("g="+Gender);
out.println("Height="+Height);
out.println("Weight="+Weight);
out.println("PStationId="+PStationId);
out.println("CrimeLevel="+CrimeLevel);
out.println("Status="+Status);
*/
Session s=HibernateUtil.getSession();
Transaction t = s.beginTransaction();
Criminal c=(Criminal)s.get(Criminal.class,Criminalid);
c.setName(Name);
c=(Criminal)s.get(Criminal.class,Criminalid);
c.setName(Name);
//sc.setGender(Gender);//this line create the proble...i.e. if we write morethan 1
// set methods it says "An Exception occured: Could not execute JDBC batch update" due to
//catch block...please help...when executing single update it run ok
s.update(c);
t.commit();
}catch(Exception e)
{
out.print("An Exception occured:\t"+e.getMessage());
}
%>