I like to store a object like:
@Table(value = "my_table")
public class MyTableDto {
@PrimaryKeyColumn(name = "uid", type = PrimaryKeyType.PARTITIONED)
@CassandraType(type = DataType.Name.UUID)
private UUID uid;
@Column(value = "child_ids")
private List<ChildIdDto> childIds;
}
Then I get the exception:
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Only primitive types are allowed inside Collections for property [childIds] of type ['interface java.util.List'] in entity [de.myapplication.repository.dto.MyTableDto]
I do understand the exception, but is there another way to persist custom objects?
EDIT:
! Never say never, I got the solution.
To give a good example, I will list all according classes.
ParentClass.java
@Table(value = "my_table") //OPT
public class MyTableDto {
@PrimaryKeyColumn(name = "uid", type = PrimaryKeyType.PARTITIONED)
@CassandraType(type = DataType.Name.UUID)
private UUID uid;
@Column(value = "child_ids") //OPT
private List<ChildDto> childIds;
}
ChildDto.java
@UserDefinedType // THE SOLUTION
public class ChildDto {
@Column(value = "child") //OPT
@CassandraType(type = DataType.Name.TEXT) //OPT
private String groupId;
@Column(value = "description") //OPT
@CassandraType(type = Name.TEXT) //OPT
private String description;
}
The @UserDefinedType is the solution.
For more information see here.
NOTE: Each annotation with "OPT" is NOT required
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With