@@ -17,9 +17,11 @@ import org.babyfish.jimmer.sql.kt.cfg.KSqlClientDsl
17
17
import org.babyfish.jimmer.sql.kt.filter.KFilterDsl
18
18
import org.babyfish.jimmer.sql.kt.filter.KFilters
19
19
import org.babyfish.jimmer.sql.kt.impl.KSqlClientImpl
20
+ import org.babyfish.jimmer.sql.runtime.ConnectionManager
20
21
import org.babyfish.jimmer.sql.runtime.EntityManager
21
22
import org.babyfish.jimmer.sql.runtime.Executor
22
23
import org.babyfish.jimmer.sql.runtime.JSqlClientImplementor
24
+ import org.babyfish.jimmer.sql.transaction.AbstractTxConnectionManager
23
25
import org.babyfish.jimmer.sql.transaction.Propagation
24
26
import java.sql.Connection
25
27
import kotlin.reflect.KClass
@@ -79,27 +81,18 @@ interface KSqlClient : KSaver {
79
81
val triggers: KTriggers
80
82
81
83
/* *
82
- * <ul>
83
- * <li>
84
- * If trigger type is 'BINLOG_ONLY'
85
- * <ul>
86
- * <li>If `transaction` is true, throws exception</li>
87
- * <li>If `transaction` is false, return binlog trigger</li>
88
- * </ul>
89
- * </li>
90
- * <li>
91
- * If trigger type is 'TRANSACTION_ONLY', returns transaction trigger
92
- * no matter what the `transaction` is
93
- * </li>
94
- * <li>
95
- * If trigger type is 'BOTH'
96
- * <ul>
97
- * <li>If `transaction` is true, return transaction trigger</li>
98
- * <li>If `transaction` is false, return binlog trigger</li>
99
- * </ul>
100
- * Note that the objects returned by different parameters are independent of each other.
101
- * </li>
102
- * </ul>
84
+ * - If trigger type is 'BINLOG_ONLY'
85
+ * - If `transaction` is true, throws exception
86
+ * - If `transaction` is false, return binlog trigger
87
+ *
88
+ * - If trigger type is 'TRANSACTION_ONLY',
89
+ * returns transaction trigger no matter what the `transaction` is
90
+ *
91
+ * - If trigger type is 'BOTH'
92
+ * - If `transaction` is true, return transaction trigger
93
+ * - If `transaction` is false, return binlog trigger
94
+ * > Note that the objects returned by different parameters are independent of each other.
95
+ *
103
96
* @param transaction
104
97
* @return Trigger
105
98
*/
@@ -253,6 +246,25 @@ interface KSqlClient : KSaver {
253
246
fun <E : Any > deleteByIds (type : KClass <E >, ids : Iterable <* >, block : KDeleteCommandDsl .() -> Unit ): KDeleteResult =
254
247
entities.deleteAll(type, ids, block = block)
255
248
249
+ /* *
250
+ * Execute a transaction by the specified [Propagation] behavior
251
+ *
252
+ * - If an IOC framework is used, its implementation
253
+ * should be an encapsulation of the transaction management
254
+ * within the IOC framework. Taking `jimmer-spring-starter`
255
+ * as an example, it is the `SpringConnectionManager`
256
+ * which will be created and enabled automatically.
257
+ *
258
+ * - If no IOC framework is used, the class
259
+ * [AbstractTxConnectionManager] is the
260
+ * lightweight implementation provided by jimmer,
261
+ * please specify the connection manager of sqlClient
262
+ * by [ConnectionManager.simpleConnectionManager]
263
+ *
264
+ * @param propagation The propagation behavior
265
+ * @param block The action to be executed in transaction
266
+ * @return The result of transaction
267
+ */
256
268
fun <R > transaction (propagation : Propagation = Propagation .REQUIRED , block : () -> R ): R
257
269
258
270
val javaClient: JSqlClientImplementor
0 commit comments