I use Hibernate with wildfly 10.0.1. And my transactions are Container managed Transaction.
I frequently get[1] OptimisticLockException
when updating the entries.
How can I handle this exception in CMT?
Why my wildfly is not managing properly?
Do I need to add any application level logic?
[1]
javax.persistence.OptimisticLockException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Persistence.xml
<persistence-unit name="apidb-persistence-unit"
transaction-type="JTA">
<description>Forge Persistence Unit</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/lobDS</jta-data-source>
<class>xx.core.model.base.CRMEntity</class>
<class>xx.model.base.Company</class>
..
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="admin" />
<property name="javax.persistence.jdbc.password" value="ss_password" />
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class, hbm" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="" />
<property name="hibernate.enable_lazy_load_no_trans" value="true" />
<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.2" />
<property name="hibernate.connection.provider_class" value="com.zaxxer.hikari.hibernate.HikariConnectionProvider" />
<property name="hibernate.hikari.minimumIdle" value="5" />
<property name="hibernate.hikari.maximumPoolSize" value="500" />
<property name="hibernate.hikari.idleTimeout" value="30000" />
<property name="hibernate.hikari.dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
<property name="hibernate.hikari.dataSource.url" value="jdbc:mysql://localhost:3306/rathadb" />
<property name="hibernate.hikari.dataSource.user" value="XX" />
<property name="hibernate.hikari.dataSource.password" value="XX" />
<property name="hibernate.hikari.dataSource.cachePrepStmts" value="true" />
<property name="hibernate.hikari.dataSource.prepStmtCacheSize" value="1000" />
<property name="hibernate.hikari.dataSource.prepStmtCacheSqlLimit" value="2048" />
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.discriminator.ignore_explicit_for_joined" value="true" />