title: Hibernate @SQLInsert and On Duplicate Key
body: <p>In Hibernate, you can use <code>@SQLInsert</code> to define a custom insert query. Hibernate is using prepared statements, so you just need to provide the <code>?</code> as placeholder, like this: <code>INSERT INTO table (colA, colB) VALUES (?,?)</code></p>
  
  <p>On a duplicate key for <code>colA</code>, I want <code>colB</code> to be updated with the new value, so i tried <code>INSERT INTO table (colA, colB) VALUES (?,?) ON DUPLICATE KEY UPDATE colB = ?</code> - This however throws the error that no third parameter is given. (<em>No value specified for parameter 3</em>) </p>
  
  <p>How is the correct way to write this Query for hibernate? Any non-data-dependent update like <code>INSERT INTO table (colA, colB) VALUES (?,?) ON DUPLICATE KEY UPDATE colB = colB +1</code> is working - but I need to set the actual value of <code>colB</code> that has been passed with the insert-call.</p>