Le dimanche 22 septembre 2013 09:03:19 UTC+2, Lukas Eder a écrit :
>
>
>> I haven't yet migrated to 3, my project is successfully using 2.6 in
>> production. As the only thing I miss in 2.x is also not present in 3.x (it
>> has to do with mybatis-like transaction management) I did not upgrade.
>> Will consider migrating during the next week..
>>
>
> I had studied MyBatis' transaction (session) management before. To me, it
> seemed to be tailored to only one JDBC transaction models, not JEE/JTA
> models, or alternative, third party models. What are the good parts of
> MyBatis' implementation, according to you?
>
>
Exactly what you said, it makes jdbc transaction handling easier for people
who don't use big frameworks.
Right now, when using a jooq factory I need to call setAutoCommit, reset it
to true in a finally clause, manually catch high level classes such as
"Exception or Throwable" and rollback.
In the case of mybatis, I do something like that (from memory)
sessionManager.startManagedSession(); //obtains a connection from the
datasource and set autommit to false, store it in a threadlocal
try {
sessionManager.select(...);
sessionManager.update(..);
sessionManager.delete(...);
new MyDao( sessionManager).doStuffWithSessionManager();
sessionManager.commitTransaction();
}
finally {
sessionManager.closeTransaction(); //rollback any uncommited change if
needed, resets autcommit and returns the connection to the datasource.
}
sessionManager.select() //do a query and immediately release the Connection
In jooq, you need to do the following :
1) set autocommit
2) catch and rewrap any Exception, yes *including unchecked ones*, in order
to be able to call rollback
3) reset autocommit in a finally clause
In jooq 2.x, I would have expected such functionality from a DataSource
based Factory, a system fetching one Connection per request and, in case
user starts a transaction, store the Connection in a threadlocal and reuse
it until it's closed.
I don't remember exactly how a DataSource based Factory currently works,
but it was clearly not that useful for people not using external
transaction managers.
But let's forget about the DataSource based Factory and think of a simple
Factory that just holds a Jdbc Connection, don't you think a few
transaction helper methods could be useful?
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.