I am using SpringBoot2 for creating microservice. Database table I am using for entity is been defined with default sequence at DB level for the primary key. Like below,
CREATE TABLE EMPLOYEE (
EMP_ID INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 .....) NOT NULL,
EMP_NAME VARCHAR2(100 BYTE))
I want the spring boot data jpa to use the above default sequence for emp id
@Entity
@Table(name="EMPLOYEE")
public class Employee {
@Id
@Column(name = "EMP_ID", insertable = false)
private Integer empId;
@Column(name = "EMP_NAME", insertable = false)
private String empName
}
I want the empId to be generated from the default sequence added in Create Table query. I tried all the strategy in GeneratedValue but it is not working. I am only left with creating explicit sequence and use it in sequence generator.