How to insert a record and have its primary key set?

2017-03-28 Thread Hilco Wijbenga
Hi all, I'm trying to (batch) insert a set of records and have their primary keys set afterwards. I have tried with both 3.6.4 and 3.9.1. We use MySQL. I started out with @SuppressWarnings({ "unchecked", "rawtypes" }) final Class> updatableRecordClass = (Class) UpdatableRecord.class; DSL

Re: batchdelete on a junction table

2017-03-28 Thread anuj0416
any insight on this would be greatly appreciated On Thursday, March 23, 2017 at 10:22:54 AM UTC-7, Anuj Kumar wrote: > > Some what related to batchUpdate() and optimistic locking. When I try to > do a batch update on a stale record it fails and does not throw any kind of > exception. For example

Re: I can't seem to find any example of how to use Existing pojos.....

2017-03-28 Thread Rob Sargent
Thank you again, all of these work: Map fullMap = new HashMap<>(); fullMap.putAll(ctx.select(PERSON.fields()) .from(PERSON.join(ALIAS) .on(PERSON.ID.equal(ALIAS.PERSON_ID))) .where(ALIAS.AKA.in(nameSet)) .fetchMa

Re: I can't seem to find any example of how to use Existing pojos.....

2017-03-28 Thread Rob Sargent
Thank you for the suggestion, which I'll try shortly. I have had success with this fullMap.putAll(ctx.selectFrom(PERSON) .whereExists(ctx.selectOne() .from(ctx.select().from(ALIAS) .where(ALIAS.AKA.in(nameSet).and(ALIAS.PERSON_ID.equal(PERSON.ID))

Re: I can't seem to find any example of how to use Existing pojos.....

2017-03-28 Thread Lukas Eder
Hmm, I thought there was a fetchMap(Field, Table) method but there isn't. In that case, you could do: DSL.using(configuration) .select(...) .from(...) .fetchMap(MY_TABLE.KEY_FIELD, r -> r.into(PERSON)); This will be using the Record.into(Table) method: https://www.jooq.org/javadoc/latest

Re: I can't seem to find any example of how to use Existing pojos.....

2017-03-28 Thread Rob Sargent
Map is a different matter I think. > On Mar 27, 2017, at 9:25 PM, Samir Faci wrote: > > fetchMap: > > Map userMapping = > complexQuery.fetchMap(schema.table.fieldname, schema.table.fieldname2); > > I've used the exact same pattern for fetchMap irrelevant of the complexity of > the SQL and