Hibernate has to make inserts in a table which has an unique field. I want to ignore duplicate entries so that my program keeps running. In MySQL I would simply say INSERT IGNORE
, but I can't figure out how to do that in Hibernate. Any suggestions? Thanks!
Have you tried using the @SQLInsert
annotation ? This way, you can overwrite the Hibernate statement with your own custom SQL and use INSERT IGNORE
:
@SQLInsert(sql="INSERT IGNORE INTO CUSTOMER(id,name) VALUES(?,?)")
class Customer{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With