本文介绍了找不到请求的操作集< varchar>的Spring Data Cassandra编解码器.<->java.util.Set的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的实体有一个字段

@Column("authorizations")
@Builder.Default
private Map<String, Set<String>> authorizations = new HashMap<>();

当我通过Spring Data存储库查询该对象时,我遇到了异常

When I query for that object via Spring Data repository I'm getting an exception

尽管写工作正常.我不敢相信不立即可用.

Writes work just fine though. I can't believe this is not supported out of the box.

表定义

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?

推荐答案

这是Spring Data Casasndra的局限性.有一个 JIRA用于改善对冷冻收藏的支持.看起来它可以与自定义行映射器一起解决,如.

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.DataStax Java驱动程序具有相应的注释在其对象映射器中.

P.S. The DataStax Java Driver has corresponding annotations in their object mapper.

这篇关于找不到请求的操作集&lt; varchar&gt;的Spring Data Cassandra编解码器.&lt;-&gt;java.util.Set的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:07