Hi Eric,

2013/9/6 Eric Schwarzenbach <[email protected]>

> Hi Lukas,
>
> Thanks for your replies. I just want to say that your openness to talking
> about consider improvements to your API is very refreshing, and an all too
> rare thing in the software world.
>

Well, if it wasn't for the great feedback I tend to get on this user group
(and on GitHub), jOOQ might be only half as good ;-)


> I would swear that when I stepped over my bind() call in the debugger I
> saw a different object returned than the query on which I executed it. I
> must have misinterpreted something.
>
> I'm happy to hear that some of these issues may be addressed in a JOOQ 4,
> and that there is a way to detach queries. Let me just make sure I'm
> interpreting your replies correctly around query objects and thread safety.
> It looks like my options are:
>
> 1) don't hold onto a query object, rebuild the query object each time I
> execute it
>

That's the easiest way. Or you can pool query objects to add thread-safety
to them, externally. For instance, using Apache Commons Pool:
http://commons.apache.org/proper/commons-pool

I'm sure Guava has some nice polling APIs as well.


> 2) build it once, extract the sql and hold onto that instead of the query
> object, and when I want to execute it, instantiate new query object, using
> DSLContext.resultQuery (in my "select" cases, at least)
>

Yes, you can do that. Others have successfully used jOOQ as a SQL builder
only, and executed the statements through Spring JDBC / JdbcTemplate for
instance. See also:
http://www.jooq.org/doc/3.1/manual/getting-started/use-cases/jooq-as-a-sql-builder-with-code-generation

I personally recommend:

a) profiling to see if there is a significant performance gain in choosing
that approach (I'd be interested in results!)
b) carefully assessing if you will then still profit from enough jOOQ
features. For instance, some type information may be lost when you operate
on Strings only.


> 3) hold onto the query object and synchronize the lines where I attach,
> bind, and execute (probably not really desirable but just listing it for
> completeness)
>

Again, if you want to reuse the query object, I'd personally prefer pooling
over explicit synchronising. But synchronising will do the job as well, of
course.

Is that right or are there other options I missed?
>

Nothing I can think of right now. Of course, as always, the group is
invited to join and participate, sharing their own experience.

Regards
Lukas

-- 
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.

Reply via email to