[CONJ-344] HibernateOptimisticLockingFailureException with Hibernate, Mariadb and Spring transactions Created: 2016-09-08 Updated: 2016-09-13 Resolved: 2016-09-13 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | None |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | sunil k | Assignee: | Diego Dupin |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We are migrating application from oracle to Mariadb. Using container transactions and Spring transaction management. I am getting error for code where the one record is saved and updated in same transaction(Service bean method). Same code is working fine for Oracle database. I am the only one who is connected to the mariadb database. Help will be appreciated. Error: org.springframework.orm.hibernate4.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 JDK: 1.6, Tomcat: 7.0.65, Spring: 4.1, hibernate: 4.2.21 mariadb version: 10.1.13-MariaDB driver: mariadb-java-client-1.1.9 Dialects: org.hibernate.dialect.MySQLInnoDBDialect and i tried with org.hibernate.dialect.MySQLDialect also same error is coming.
Service class method
Dao class methods:
Queries generated after control coming out of service method
|
| Comments |
| Comment by Diego Dupin [ 2016-09-09 ] |
|
Hi, Can you send the connection url you use to connect to connect mariadb server ?
"insert into DEAL (INT_DEAL_ID, DEAL_DESC, LAST_UPDATED_ID, CREATION_DATE, CREATION_DATE_USER_TZ, END_DATE, SK_DEAL_ID) values (?, ?, ?, ?, ?, ?, ?)" "update DEAL set INT_DEAL_ID=?, DEAL_DESC=?, LAST_UPDATED_ID=?, CREATION_DATE=?, CREATION_DATE_USER_TZ=?, END_DATE=? where SK_DEAL_ID=? and LAST_UPDATED=?" changind DDL from timestamp(0) to timestamp(6) will correct this. |
| Comment by sunil k [ 2016-09-10 ] |
|
Hi Diego, Thank you for your help, it worked after changing the last_updated(@version) column type from datetime to datetime(6). Thanks, |
| Comment by Diego Dupin [ 2016-09-13 ] |
|
you're welcome. |