Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto commit is always false #765

Open
benhasselgren opened this issue Oct 20, 2024 · 1 comment
Open

Auto commit is always false #765

benhasselgren opened this issue Oct 20, 2024 · 1 comment

Comments

@benhasselgren
Copy link

benhasselgren commented Oct 20, 2024

It appears that auto commit is false when you are executing a mapper statement in a method NOT decorated with @Transactional annotation. I verified this by sticking a breakpoint on JdbcTransactionFactory.newTransaction(DataSource ds, TransactionIsolationLevel level, boolean autoCommit) (My default data source auto commit value is set to true. I am using Hikari CP). Is this the expected behaviour? If so, it would be nice if there was some config in the MyBatisModule to allow you to set the default auto commit value for all query behaviour not wrapped within the transactional annotation.

@christianpoitras
Copy link
Member

Based on HikariCPProviderTest.java and your comment, the auto commit flag on the DataSource is correct (true).
MyBatis-Guice does not handle transactions that are outside a @Transactional annotation. In such cases, it is relying on MyBatis code only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants