Multiple queries in single transaction

21 views
Skip to first unread message

Shweta Kaushal

unread,
Sep 22, 2022, 5:12:52 AM9/22/22
to jDBI
Hi,

I wan to run multiple delete and create queries in single transaction. How to do it with JDBI?



Matthew Hall

unread,
Sep 22, 2022, 9:37:20 AM9/22/22
to jd...@googlegroups.com
When using Handle, use the Handle.inTransaction method (to return a result) or Handle.useTransaction method (does not return a result). Any SQL statements you execute inside the transaction callback will be part of the transaction.


When using SQL objects, annotate the method with a @Transaction annotation--typically on an interface default method. Any SQL statements you execute inside that method (including calls to other methods on the SQL object interface) will be part of the transaction.


If it's important that your query results match a particular snapshot of the database, you will want to configure the transaction isolation to the appropriate level when you open the transaction.

Hope this helps!

-Matthew

On Thu, Sep 22, 2022, 3:12 AM Shweta Kaushal <shweta.k...@gmail.com> wrote:
Hi,

I wan to run multiple delete and create queries in single transaction. How to do it with JDBI?



--
You received this message because you are subscribed to the Google Groups "jDBI" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jdbi+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jdbi/cb68a1c0-8aa9-4540-b402-0ea3566493b5n%40googlegroups.com.

Shweta Kaushal

unread,
Sep 25, 2022, 9:37:34 AM9/25/22
to jd...@googlegroups.com
It worked.. Thank you!

Reply all
Reply to author
Forward
0 new messages