关于hibernate报错问题

遇到进行saveOrUpdate的时候新增数据hibernate报错

2018-07-31 14:15:31 ERROR [org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution:124] HHH000315: Exception executing batch [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]
2018-07-31 14:15:31 ERROR [org.hibernate.internal.SessionImpl$5.mapManagedFlushFailure:3166] HHH000346: Error during managed flush [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]
2018-07-31 14:15:31 ERROR [com.fanzhuo.ibms.base.web.DeviceWeb.save:182] Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
org.springframework.orm.hibernate5.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
 

原因是因为主键传递的时候传了一个空的字符串而不是null,所以无法进行新增。

你可能感兴趣的:(关于hibernate报错问题)