Skip to content

returnGeneratedKeys with auto commit enabled #20

Closed
@kdurnoga

Description

@kdurnoga

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions