Scenario: I do have JSON object as Menus.
//suppose this as
Menus menus = new Menus();
menus.setId(61);
menus.setUrl("test_url");
menus.setName("menu name");
repository.save(menus);
Current case:
- It is working fine if db has menu row with id 61 as a result object gets updated.
- While row with id=61 does not exists in db then this menu object gets persisted but with new id. ie. a new row is created with new auto generated ID.
Expected:
- If menu where id = 61 does not exists in db then menus should be inserted in db with id=61
package com.rasello.auth.entity;
import lombok.*;
import org.hibernate.annotations.Type;
import javax.persistence.*;
@Entity
@Data
@NoArgsConstructor
@Table(name = "menus")
@Getter
@Setter
public class Menus {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
private String name;
private String url;
}