org.hibernate.exception.DataException: could not execute native bulk manipulation query

使用hibernatede 时遇到了下面的错误。google了一下,只要在连接字符串中设置

<property name="connection.url">jdbc:mysql://localhost:4406/wrzl?jdbcCompliantTruncation=false</property>

属性即可。问题解决,不知到有没有副作用。观察中。。。。。。。

native

  • adj. 本国的;土著的;天然的;与生俱来的;天赋的
  • n. 本地人;土产;当地居民
manipulation
  • n. 操纵;操作;处理;篡改

bulk

  • n. 体积,容量;大多数,大部分;大块
  • vt. 使扩大,使形成大量;使显得重要

 // 执行原生的insert 等SQL语句
    public void executeUpdateSql(String sql) throws HibernateException, SQLException {       
        Session session = getSession();
        Transaction ts = null;
        try {
            ts = session.beginTransaction();
            SQLQuery query = session.createSQLQuery(sql);
            query.executeUpdate();           
            ts.commit();
            //log.debug("save successful");
        } catch (RuntimeException re) {
            //log.error("save failed", re);
            ts.rollback();
            throw re;
        } finally{
            closeSession();
        }
    }

2011-8-29 13:40:16 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: Data truncation: Out of range value for column 'XST_jbqyxzt1' at row 120
org.hibernate.exception.DataException: could not execute native bulk manipulation query
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:198)
    at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1191)
    at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:357)
    at cn.com.bcsoft.dao.BaseHibernateDAO.executeUpdateSql(BaseHibernateDAO.java:118)
    at cn.com.bcsoft.backgroud.Handler.insertDB(Handler.java:999)
    at cn.com.bcsoft.backgroud.Handler.run(Handler.java:209)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'XST_jbqyxzt1' at row 120
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3595)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
    at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:189)
    ... 8 more

原文地址:https://www.cnblogs.com/leelike/p/2158123.html