I am running into problems when persisting an Entity using hibernate (4.2.7) in an ejb application. Below are the configuration for the transaction factory and transaction manager in my hibernate configuration file.
Code:
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
</property>
whenever there is an SQL exception for example, passing an null value to a not null column, constraint issue etc, we are getting the below exception
Code:
[5/22/16 15:15:21:481 MYT] 000000b7 RegisteredSyn E WTRN0074E: Exception caught from before_completion synchronization operation: java.lang.UnsupportedOperationException
at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.setRollbackOnly(WebSphereExtendedJtaPlatform.java:139)
at org.hibernate.engine.transaction.internal.jta.CMTTransaction.markRollbackOnly(CMTTransaction.java:131)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.setRollbackOnly(TransactionCoordinatorImpl.java:306)
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.setRollbackOnly(SynchronizationCallbackCoordinatorImpl.java:127)
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:117)
at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53)
at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter$TransactionAdapter$1.invoke(WebSphereExtendedJtaPlatform.java:176)
at com.sun.proxy.$Proxy75.beforeCompletion(Unknown Source)
Because of which we are unable to determine what is the actual issue, Our database is Oracle. Is there any way that we can get the exact SQLException thrown ?
Pls note:
After changing the same to org.hibernate.transaction.WebSphereTransactionManagerLookup, we are getting the exact SQLException.
Code:
[5/24/16 18:43:33:561 GMT+08:00] 000000b6 SystemErr R Caused by: java.sql.SQLException: ORA-12899: value too large for column "ICMDEV"."CUST_EMPLOYMENTS"."PROFESSION_CODE" (actual: 7, maximum: 3)
[5/24/16 18:43:33:561 GMT+08:00] 000000b6 SystemErr R
[5/24/16 18:43:33:561 GMT+08:00] 000000b6 SystemErr R at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
[5/24/16 18:43:33:561 GMT+08:00] 000000b6 SystemErr R at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
[5/24/16 18:43:33:561 GMT+08:00] 000000b6 SystemErr R at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.ja