问题
My entity has a field
@Column("authorizations")
@Builder.Default
private Map<String, Set<String>> authorizations = new HashMap<>();
When I query for that object via Spring Data repository I'm getting an exception
CodecNotFoundException: Codec not found for requested operation: [set <-> java.util.Set]
Writes work just fine though. I can't believe this is not supported out of the box.
Table definition
CREATE TABLE resource_authorization_rules(
resource text,
region text,
authorizations map<text, frozen<set<text>>>,
PRIMARY KEY (resource, region)
);
Probably something with type erasure. How to tackle this with least effort?
回答1:
This is a limitation of the the Spring Data Casasndra. There is a JIRA for improving support of frozen collections. And it looks like that it could be worked around with custom row mapper as described here.
P.S. The DataStax Java Driver has corresponding annotations in their object mapper.
来源:https://stackoverflow.com/questions/51541002/spring-data-cassandra-codec-not-found-for-requested-operation-setvarchar-j