Spring Data Cassandra codec not found for requested operation set<varchar> <-> java.util.Set

邮差的信 提交于 2019-12-13 03:14:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!