教育網研究一 hibernate 插入和儲存對象

來源:互聯網
上載者:User

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.*;

</

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.