The future changes you describe make a lot of sence. I've played around with my utility classes a little more since my last post (I realized the silliness of my ExceptionFactory throwException methods and changed them to getException methods) and combined the ability to do single-execute-and-cleanup methods into my 2-class approach, to have the best of both worlds. I mispoke in saying that the factory did the connection getting and closing...it is actually the executor class. Because there are now multiple files its awkward to paste in so I'll attach a zip. A quick example of its use though:
*public* Collection<Something> getSomething() *throws* ServiceException {
JooqExecutorF jooqExecutor = jooqExecutorFactory.getExecutor();
SelectLimitStep query = jooqExecutor.getJooqFactory().select(*
SOMETHING.SOMETHING*)...
// etc. etc. lots of DSL query building here
Result<Record> result = jooqExecutor.doFetch(query);
// do something with result; more statements could be executed
jooqExecutor.cleanUp();
r*eturn* something;
}
If the code calls doFetch1Shot(query), it can omit the cleanUp() call. Also
this code assumes a
JooqExecutorFactory has already been created (and perhaps
dependency-injected) giving it a DataSource and ExceptionFactory that
throws ServiceExceptions
At the moment I have 2 sets of methods for execution methods, one that
doesn't clean itself up right away, and one that that does (...1Shot). This
is rather ugly, but it is a work in progress.
JooqExecutorFactory.7z
Description: application/7z-compressed
