I have a Mysql table like below :
CREATE TABLE ABCD
(
TId BIGINT(8) PRIMARY KEY AUTO_INCREMENT,
TKey VARCHAR(200) NOT NULL,
TValue BIGINT(8) NOT NULL
);
it has data like below :
TId TKey TValue
1 abc 123
2 cde 345
3 def 546
What i want to do is , if i again insert entity with same TKey it'll update existing record instead of inserting new one.
Below is my code to save entity :
ABCD abcd = new ABCD();
abcd.setKey(key);
abcd.setValue(value);
abcdService.create(abcd);
TId TKey TValue4 cde 789. What i want to do is it should update TId -> 2 with 789.