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

returnGeneratedKeys with auto commit enabled #20

Closed
kdurnoga opened this issue Jan 29, 2018 · 3 comments
Closed

returnGeneratedKeys with auto commit enabled #20

kdurnoga opened this issue Jan 29, 2018 · 3 comments

Comments

@kdurnoga
Copy link

kdurnoga commented Jan 29, 2018

When I use the returnGeneratedKeys method with auto commit enabled then an error is emitted downstream. Namely, the code of this form

db.update("INSERT INTO table1(col1, col2, col3) VALUES(?, ?, ?)")
	.parameters("param1", "param2", "param3")
	.returnGeneratedKeys()
	.autoMap(MyClass.class)
	.singleOrError();

correctly emits an inserted object but the following error is raised on completion:

org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.

It looks like a flowable constructed by returnGeneratedKeys performs a commit on completion and is oblivious to the fact that the underlying connection has auto commits enabled. Connection pools with auto commit enabled seem to be the default(?).
Am I doing something wrong?

@davidmoten
Copy link
Owner

blocking or non-blocking connection pool?

@davidmoten
Copy link
Owner

Ok, I've added a check on getAutoCommit() value before I call commit or rollback (and a unit test). Let me know if that has you sorted. Deployed to Maven Central as 0.1-RC30.

@kdurnoga
Copy link
Author

It works! Thank you for the prompt reaction.

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