I am inserting data into a table daily. Suppose today i have inserted a row with values x,y and z , Suppose tomorrow again i get same data x,y and z at this timei dont want to insert this data into DB. How can we do it in easiest way using hibernate.
My goal is to avoid duplicate rows .
Your quick response will be appreciated.
let say my table has four columns and first column is a serial , suppose i entered a row with values john,english,UK and again some one try to insert a row with values john,english,UK . So how i can avoid this insert in HIBERNATE.
What is the best way to stop this 2nd time insert for same data.
posted 3 years ago
For MySQL you would do something like:
ADD UNIQUE 'my_index'('column1', 'column2', 'column3)
The first place to ensure this is the db itself.
For Hibernate you would use the @UniqueConstraint annotation for the table, which should add the equivalent of the above when it creates the table.