You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have multiple queries that run depending on some conditions inside a transaction. If all the conditions are false no query is run and transaction fails with the exception:
org.codejargon.fluentjdbc.api.FluentJdbcSqlException: Error executing transaction
at org.codejargon.fluentjdbc.internal.query.TransactionInternal.lambda$inNewTransaction$1(TransactionInternal.java:68)
at org.codejargon.fluentjdbc.api.integration.providers.DataSourceConnectionProvider.provide(DataSourceConnectionProvider.java:23)
at org.codejargon.fluentjdbc.internal.query.TransactionInternal.inNewTransaction(TransactionInternal.java:51)
at org.codejargon.fluentjdbc.internal.query.TransactionInternal.in(TransactionInternal.java:36)
at org.codejargon.fluentjdbc.internal.query.TransactionInternal.inNoResult(TransactionInternal.java:42)
...
Caused by: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
at org.postgresql.jdbc.PgConnection.commit(PgConnection.java:854)
at com.zaxxer.hikari.pool.ProxyConnection.commit(ProxyConnection.java:366)
at com.zaxxer.hikari.pool.HikariProxyConnection.commit(HikariProxyConnection.java)
at org.codejargon.fluentjdbc.internal.query.TransactionInternal.lambda$inNewTransaction$1(TransactionInternal.java:66)
Pseudocode:
query.transaction().inNoResult(() ->
if (condition1) {
var condition3 = query.update();
}
if (condition2 || condition3) {
query.update()
}
if (condition3) {
query.update()
}
)
This happens because the connection is committed while having autoCommit = true as the transaction wasn't actually started.
I suggest avoiding connection commit if it has autoCommit = true. Please see my PR.
The text was updated successfully, but these errors were encountered:
I have multiple queries that run depending on some conditions inside a transaction. If all the conditions are false no query is run and transaction fails with the exception:
Pseudocode:
This happens because the connection is committed while having
autoCommit = true
as the transaction wasn't actually started.I suggest avoiding connection commit if it has
autoCommit = true
. Please see my PR.The text was updated successfully, but these errors were encountered: