剛剛開始接觸Hibernate編程,第一次寫個小項目,就遇到這個問題,弄明白怎麼回事後,記錄下來了!
錯誤:
org.hibernate.exception.GenericJDBCException: could not insert: [vo.User]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2093)
錯誤原因:我在數據庫設計時候,沒有給ID設置爲自增,做添加操作時,也沒有給其賦值,所以才插入異常。