I have a cassandra table with primary key column “id”. I need to add list of students with “first_name”, “last_name”, and “age” fields. How can i add student list to table, where “id” column should be filled automatically with auto incremented value starting from 1?
0
votes
1 Answers
0
votes
Add this in your entity class
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(columnDefinition = "serial")
private Long id;
Spring Boot will automatically increment the id. There are other ways to automatically change the value. The value of strategy can be AUTO, TABLE, SEQUENCE, or IDENTITY.
I would recommend using the SEQUENCE GENERATOR