I came up with an API for batch operations. It is not part of the
org.jooq.Query API, but a method in the factory. It has two modes:
1. Execute several queries without bind values
create.batch(query1, query2, query3)
.execute();
2. Execute one query several times with bind values
create.batch(query)
.bind(valueA1, valueA2)
.bind(valueB1, valueB2)
.execute();
These two modes reflect what JDBC supports on a 1:1 basis.
So this is implemented and functional:
https://sourceforge.net/apps/trac/jooq/ticket/621
It can be found on SVN trunk, Github, and on the Sonatype Maven
Snapshot repository:
https://oss.sonatype.org/content/repositories/snapshots/org/jooq/
If you like, you can now donate or blog about jOOQ :-)
Cheers
Lukas
2011/10/25 Lukas Eder <[email protected]>:
> Hello,
>
>> I know it's
>> on the TODO but I did read it was a low priority, so just here to give
>> my point of view about this feature :p Thanks.
>
> Nothing wrong with that :-)
>
>> Hello, I think addBatch feature is missing in your framework, imo it's
>> an important feature because it can have a serious performances
>> impact, specially when you do update of multiples records.
>
> I agree. The reason why I set it to low prio at the moment is because
> I don't have a clear feeling about the API design. With JDBC, you can
> simply "serialize" every single insert's / update's bind variables,
> while re-using the actual statement itself. For jOOQ, this is a bit
> different. When you write
>
> create.update(T_AUTHOR)
> .set(TAuthor.FIRST_NAME, "Hermann")
> .set(TAuthor.LAST_NAME, "Hesse")
> .where(TAuthor.ID.equal(3))
>
> You'll have three bind variables: "Herman", "Hesse", 3
> Now, let's say you want to update a second record in batch mode:
> "Günter", "Grass", 4
>
> How to add more bind variables and execute the whole query as a batch
> query? Like this?
>
> create.update(T_AUTHOR)
> .set(TAuthor.FIRST_NAME, "Hermann")
> .set(TAuthor.LAST_NAME, "Hesse")
> .where(TAuthor.ID.equal(3))
> .addBatch("Günter", "Grass", 4)
> .addBatch(...)
> .execute();
>
> That's a bit awkward... I'm open to ideas!
>
> Cheers
> Lukas
>