Hi,
I have use jooq-spring transaction example (the same configuration)
https://github.com/jOOQ/jOOQ/tree/master/jOOQ-examples/jOOQ-spring-example

I have one @Transactional method with first successfull insert and next 
insertNode with Duplicate entry error and expect data from the first insert 
not to be written in Database but this not happen.

@Transactional//(rollbackFor = Exception.class)
public Integer insert(Integer parentGroupsId, Groups groups) throws Exception {
    Integer groupsId = groupsDAO.insert(groups);   
    if (groupsId != null) {
        groupsDAO.insertNode(groupsId, parentGroupsId);
    }
    return groupsId;
}

I have check with breakpoints:

08:38:09,143 DEBUG DefaultListableBeanFactory:248 - Returning cached instance 
of singleton bean 'transactionManager'
08:38:09,146 DEBUG DataSourceTransactionManager:367 - Creating new transaction 
with name [com.my.db.service.GroupsServiceImpl.insert]: 
PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
08:38:09,147 DEBUG DataSourceTransactionManager:206 - Acquired Connection 
[ConnectionJavassistProxy(242059657) wrapping 
com.mysql.jdbc.JDBC4Connection@38ef01a2] for JDBC transaction
08:38:09,149 DEBUG DataSourceTransactionManager:223 - Switching JDBC Connection 
[ConnectionJavassistProxy(242059657) wrapping 
com.mysql.jdbc.JDBC4Connection@38ef01a2] to manual commit
08:38:09,150 TRACE TransactionSynchronizationManager:193 - Bound value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] to thread [qtp1653844940-54]
08:38:09,150 TRACE TransactionSynchronizationManager:272 - Initializing 
transaction synchronization
08:38:09,150 TRACE TransactionInterceptor:484 - Getting transaction for 
[com.stil.db.service.GroupsServiceImpl.insert]

////breackpoint between two inserts. I have check that first insert is not 
written in DB table yet.

INFO SQLErrorCodesFactory:126 - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, 
Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
08:41:08,259 DEBUG SQLErrorCodesFactory:182 - SQL error codes for 'MYSQL' not 
found
08:41:08,260 DEBUG SQLErrorCodeSQLExceptionTranslator:281 - Unable to translate 
SQLException with Error code '1062', will now try the fallback translator
08:41:08,261 DEBUG SQLStateSQLExceptionTranslator:96 - Extracted SQL state 
class '23' from value '23000'
08:41:08,264 TRACE TransactionSynchronizationManager:140 - Retrieved value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] bound to thread [qtp1653844940-54]
08:41:08,266 TRACE TransactionSynchronizationManager:140 - Retrieved value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] bound to thread [qtp1653844940-54]
08:41:08,268 TRACE TransactionSynchronizationManager:140 - Retrieved value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] bound to thread [qtp1653844940-54]
08:41:08,277 TRACE TransactionSynchronizationManager:140 - Retrieved value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] bound to thread [qtp1653844940-54]
08:41:13,305 TRACE TransactionInterceptor:528 - Completing transaction for 
[com.stil.db.service.GroupsServiceImpl.insert] after exception: 
org.springframework.dao.DataIntegrityViolationException: jOOQ; SQL []; 
Duplicate entry '67' for key 'rgt'; nested exception is 
java.sql.BatchUpdateException: Duplicate entry '67' for key 'rgt'
08:41:13,305 TRACE RuleBasedTransactionAttribute:131 - Applying rules to 
determine whether transaction should rollback on 
org.springframework.dao.DataIntegrityViolationException: jOOQ; SQL []; 
Duplicate entry '67' for key 'rgt'; nested exception is 
java.sql.BatchUpdateException: Duplicate entry '67' for key 'rgt'
08:41:13,306 TRACE RuleBasedTransactionAttribute:148 - Winning rollback rule 
is: null
08:41:13,306 TRACE RuleBasedTransactionAttribute:153 - No relevant rollback 
rule found: applying default rules
08:41:13,307 TRACE DataSourceTransactionManager:939 - Triggering 
beforeCompletion synchronization
08:41:13,308 DEBUG DataSourceTransactionManager:847 - Initiating transaction 
rollback
08:41:13,308 DEBUG DataSourceTransactionManager:284 - Rolling back JDBC 
transaction on Connection [ConnectionJavassistProxy(242059657) wrapping 
com.mysql.jdbc.JDBC4Connection@38ef01a2]
08:41:13,309 TRACE DataSourceTransactionManager:968 - Triggering 
afterCompletion synchronization
08:41:13,310 TRACE TransactionSynchronizationManager:331 - Clearing transaction 
synchronization
08:41:13,310 TRACE TransactionSynchronizationManager:243 - Removed value 
[org.springframework.jdbc.datasource.ConnectionHolder@4601de39] for key 
[HikariDataSource (springHikariCP)] from thread [qtp1653844940-54]
08:41:13,312 DEBUG DataSourceTransactionManager:327 - Releasing JDBC Connection 
[ConnectionJavassistProxy(242059657) wrapping 
com.mysql.jdbc.JDBC4Connection@38ef01a2] after transaction
08:41:13,312 DEBUG DataSourceUtils:327 - Returning JDBC Connection to DataSource

but after transaction Rolling back the first insert is written in DB. Why??




-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to