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

Savepoint/Nested Transactions support? #320

Closed
canni opened this issue Jun 5, 2018 · 1 comment
Closed

Savepoint/Nested Transactions support? #320

canni opened this issue Jun 5, 2018 · 1 comment

Comments

@canni
Copy link

canni commented Jun 5, 2018

I couldn't find any info on this, does exposed support SAVEPOINTs / nested transactions?

It's really helpful when testing and your DB (i.e. Postgres/SQLite) supports transnational DDL

@Tapac
Copy link
Contributor

Tapac commented Jun 5, 2018

Only through using a raw connection. I.e. you can use something like:

fun withSavepoint(errorMsg: ((Exception) -> String)? = null, body: () -> Unit)  {
    with(TransactionManager.current()) {
         val savepoint = connection.setSavepoint()
        try {
            body()
            connection.releaseSavepoint(savepoint)
        } catch (e: Exception) {
            connection.rollback(savepoint)
        }
    }
}

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

No branches or pull requests

2 participants