Hibernat使用中遇到的org.hibernate.exception.GenericJDBCException異常
阿新 • • 發佈:2019-01-24
在我做的專案中,儲存一個物件(提交表單時),出現了這個異常。並且提示出:
Could not execute JDBC batch update
詳細資訊如下:
- HTTP Status 500 -
- --------------------------------------------------------------------------------
- type Exception report
- message
- description The server encountered an internal error () that prevented it from fulfilling
- exception
- org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
- org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
- org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
- org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
- org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
- org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
- org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
- org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:
- org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
- org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
- org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
- org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
- org.qpyong.emp.dao.WorkersInfoDAO.merge(WorkersInfoDAO.java:191)
- org.qpyong.emp.servlet.EmployeeServlet.actionForUpdate(EmployeeServlet.java:323)
- org.qpyong.emp.servlet.EmployeeServlet.doPost(EmployeeServlet.java:56)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
- org.qpyong.emp.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:40)
- org.qpyong.emp.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:40)
- note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
- 注意到以上程式碼中 紅色粗體字沒有?剛開始我怎麼也找不到原因。然後在之後的不段測試中,無意間解決了問題。
- 即:發生這個錯誤的很可能的原因就是:這個物件對應的表的某個(些)欄位的長度不夠。
- 比如我原來的資料庫中的 workdate 欄位是 DATE 型別,長度是8。後來我把其型別改為VARCHAR,但我卻忘了把其長度改了過來,因為在頁面中我使用的是日曆控制元件,所以長度為11位。所以就丟擲了這個異常。