Hello,

Factory.newRecord(AA, a) is a shortcut for writing:

AaRecord r = Factory.newRecord(AA);
r.from(a);

The Record.from(Object) method's Javadoc explains the behavour:

General notesThe resulting record will have its internal "changed" flags
set to true for all values. This means that
UpdatableRecord.store()<http://www.jooq.org/javadoc/latest/org/jooq/UpdatableRecord.html#store()>
will
perform an INSERT statement. If you wish to store the record using an
UPDATE statement,
use 
Factory.executeUpdate(UpdatableRecord)<http://www.jooq.org/javadoc/latest/org/jooq/impl/Factory.html#executeUpdate(R)>
 instead.


http://www.jooq.org/javadoc/latest/org/jooq/Record.html#from(java.lang.Object)

Unfortunately, you will not be able to influence the behaviour of for
batchStore(). In future versions of jOOQ, the internal "changed" flags can
be modified in a way to trigger UPDATE statements, rather than INSERT
statements. As of now, you have these options:

- Tamper with the internal flags through reflection
- Explicitly phrase a set of jOOQ Update statements and pass those to
jOOQ's batch execution API
- Update records one by one using Factory.executeUpdate

Your kind of issue has been seen on this user group very often. I wonder if
it is time to introduce a batchUpdate(UpdatableRecord...) and
batchInsert(UpdatableRecord...) method. I have added relevant feature
requests for this:
- https://github.com/jOOQ/jOOQ/issues/2160 (batchUpdate)
- https://github.com/jOOQ/jOOQ/issues/2161 (batchInsert)

Cheers
Lukas


2013/2/2 primoz susa <[email protected]>

> I am wondering if batch is working for others or i am doing something
> wrong... I am using jooq maven 2.6.1
>
>         List<AaRecord> aaRecords = create.fetch(AA);
>
>         for (Aa a : aas) {
>             AaRecord r = create.newRecord(AA, a);
>             aaRecords.add(r);
>         }
>
>         // Batch-update and/or insert all of the above books
>         // everything fine till here but record is not inserted into
> table.... I have problem with insert and Aa is pojo object.
>         create.batchStore(aaRecords);
>
> Cheers
> Primoz
>
> --
> 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.
>
>
>

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