title: INSERT .. SELECT with some default values in MySQL with JOOQ
body: <p>Lets say I have a table <code>Person(id, fname, lname)</code> and it contains a record <code>(1, 'Michael', 'Bay')</code>. Now I wish to create another record in <code>Person</code> table with the same fname and lname but different id i.e. <code>(453456, 'Michael', 'Bay')</code>. This is the way I would do in plain SQL</p>
  
  <pre class="lang-sql prettyprint-override"><code>INSERT INTO Person(id, fname, lname)
  SELECT 453456, Person.fname, Person.lname
  FROM Person
  WHERE Person.id = 1; 
  </code></pre>
  
  <p>How can this be done with JOOQ (ideally while retaining JOOQ's code generation and type safety features)?</p>
  
  <p>I am aware that JOOQ provides ability to copy entire records from one table to same or another table with its <code>selectFrom</code> syntax</p>
  
  <pre class="lang-java prettyprint-override"><code>jooq.insertInto(PERSON)
        .select(selectFrom(PERSON).where(PERSON.ID.eq(1)))
        .execute();
  </code></pre>
  
  <p>But in my case, there are only certain columns in the record that I need to copy while the rest of the values needed to be set explicitly</p>
  
  <p>Another solution I could think of is the following</p>
  
  <pre class="lang-java prettyprint-override"><code>jooq.insertInto(PERSON)
        .values(452452)
        .execute();
  
  jooq.update(PERSON)
    .set(row(PERSON.FNAME, PERSON.LNAME),
         select(PERSON.FNAME, PERSON.LNAME)
        .from(PERSON)
        .where(PERSON.ID.eq(1)))
    .where(PERSON.ID.eq(452452))
    .execute();
  </code></pre>
  
  <p>But it doesn't feel right. I would be grateful if someone could provide any other solution/workaround for this problem.</p>