title: Returning count of updated rows when UPserting to a Postgres table using jOOQ
body: <p>I am upserting some data to a Postgres table using jOOQ's <code>insertInto()</code> and <code>onDuplicateKeyUpdate()</code> methods. I want to know later how many duplicates were in my data and hence need to return if a row was <strong>inserted or updated</strong>.</p>
  
  <p>From my postgres specific <a href="https://stackoverflow.com/a/47001830/3872773">research</a> so far, I found <code>RETURNING (not MY_TABLE.xmax = 0) AS updated</code> to be a valid option. However, the auto-generated Java table classes from jOOQ don't seem to give me access to the system columns of postgres like xmax.</p>
  
  <p>Here is my query so far:</p>
  
  <pre><code>dsl.insertInto(MY_TABLE)
          .columns(
                  // pkey columns
                  MY_TABLE.SHIFT,
                  MY_TABLE.DATE_UTC,
                  MY_TABLE.TIME_UTC,
  
                  MY_TABLE.DURATION,
          )
          .values(
                  shiftId,
                  utcDateId,
                  utcTime,
                  duration
          )
          .onDuplicateKeyUpdate()
          .set(MY_TABLE.DURATION, newDuration)
          .returning((MY_TABLE.xmax = 0).`às`("inserted"))
          .execute()
  </code></pre>
  
  <p>This causes the following compile time error:</p>
  
  <blockquote>
    <p>Error: Kotlin: Unresolved reference: XMAX</p>
  </blockquote>
  
  <p>I have rechecked my Maven jOOQ table generation configuration and I am not excluding any columns. I have also read through everything I could find on jOOQ's own website but found no useful information for this specific use-case. </p>
  
  <p>Any tips on what I could do here?</p>