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