我有一个类,它的字段类型为map<string,list>,我无法将这个bean保存在cassandra中。尝试使用cassandra模板插入实体时出现以下错误。我创造了 CassandraMappingContext
并设定了 userTypeResolver
也。
[Exception in request ] [org.springframework.data.mapping.MappingException: Cannot resolve value type for java.util.Map<java.lang.String,java.util.List<java.lang.String>>.
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.lambda$getMapDataType$13(CassandraMappingContext.java:702)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataTypeWithUserTypeFactory(CassandraMappingContext.java:639)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getMapDataType(CassandraMappingContext.java:694)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataTypeWithUserTypeFactory(CassandraMappingContext.java:639)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataTypeWithUserTypeFactory(CassandraMappingContext.java:587)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataType(CassandraMappingContext.java:547)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getPropertyTargetType(MappingCassandraConverter.java:725)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.lambda$getTargetType$3(MappingCassandraConverter.java:718)
at java.util.Optional.orElseGet(Optional.java:267)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getTargetType(MappingCassandraConverter.java:706)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getWriteValue(MappingCassandraConverter.java:747)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.writeUpdateFromWrapper(MappingCassandraConverter.java:478)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:383)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:365)
at org.springframework.data.cassandra.core.QueryUtils.createUpdateQuery(QueryUtils.java:132)
at org.springframework.data.cassandra.core.CassandraTemplate.update(CassandraTemplate.java:584)
at org.springframework.data.cassandra.core.CassandraTemplate.update(CassandraTemplate.java:571)
看起来Map中的值只能是基元数据类型。Spring Data Cassandra版本是 2.1.5RELEASE
但是如果我直接将这个字段保存在db中,并尝试从代码中运行getapi来获取数据,我就能够正确地获取字段。
在代码中保存数据时我做错了什么?
暂无答案!
目前还没有任何答案,快来回答吧!