hibernate保存出错
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
更新报错怎么办
原来是有取值为空
DBOperate dbo = new DBOperate();
news_inf inf1 = new news_inf();
inf1 = (news_inf) dbo.getObjetctById(inf1, "news_inf", request.getParameter("id"));//先这里取值为空了
// inf1.setId(PubFunc.parseInt(request.getParameter("id")));//这句可以不要的
inf1.setTitle(new String(request.getParameter("title").getBytes("gb2312"), "iso-8859-1"));//我有过滤器,不用考虑写反了
inf1.setDatetime(d.toLocaleString());
inf1.setTypeid(PubFunc.parseInt(request.getParameter("typeid")));
inf1.setFrees(request.getParameter("frees"));
inf1.setNewss(request.getParameter("newss"));
inf1.setRedian(request.getParameter("redian"));
inf1.setContent(new String(request.getParameter("content").getBytes("gb2312"),"iso-8859-1"));
dbo.insert_update(inf1, "update");
这里把我的 DBOperate.java也帖出来
package com.pp.db;
import my.HibernateUtil;
import java.sql.*;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.*;
import javax.naming.*;
import com.jetsum.util.PubFunc;
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
import jxl.*;
import java.io.FileInputStream;
import java.io.File;
import my.bean.member;
import java.sql.PreparedStatement;
import java.io.*;