I am using
Java: 19 Springboot: 3.0
Dependency
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</dependency>
Entity class
@Table
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Player {
@PrimaryKey
private UUID id;
Would like to know if there is anything like
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
that we can use with it.
CodePudding user response:
It can be achieved either using @CassandraType annotation in combination with the com.datastax.driver.core.DataType.Name.UUID
@Table
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Player {
@PrimaryKey
@CassandraType(type = DataType.Name.UUID)
private UUID id;
or @CassandraType annotation with the com.datastax.driver.core.DataType.Name.TIMEUUID
@Table
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Player {
@PrimaryKey
@CassandraType(type = DataType.Name.TIMEUUID)
private UUID id;
CodePudding user response:
One way is assigning default during declaration value like
private UUID id = UUID.randomUUID();
but still, I consider this as a workaround.