Collections$UnmodifiableRandomAccessList<E> Cassandra Frozen Map

Posted

技术标签:

【中文标题】Collections$UnmodifiableRandomAccessList<E> Cassandra Frozen Map【英文标题】: 【发布时间】:2019-12-20 01:48:02 【问题描述】:

我的表中有一个下面的 UDT

productsinfo FROZEN<productsinfo>

这是 productsinfo 的 UDT 架构

"owned_product_details" map<text, FROZEN<list<FROZEN<productdetails>>>>,
"available_product_details" map<text, FROZEN<list<FROZEN<productdetails>>>>

产品详情UDT有一些文本字段

当我尝试使用 Java 插入值时,它会抛出异常

java.lang.NullPointerException: at index 1
at com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:239)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:230)
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:225)
at com.google.common.collect.ImmutableList.construct(ImmutableList.java:281)
at com.google.common.collect.ImmutableList.of(ImmutableList.java:85)
at com.datastax.driver.core.DataType.map(DataType.java:462)
at com.datastax.driver.core.DataType.map(DataType.java:475)
at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.getDataTypeFor(BasicCassandraPersistentProperty.java:223)
at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.findDataType(BasicCassandraPersistentProperty.java:186)
at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.getDataType(BasicCassandraPersistentProperty.java:169)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataTypeWithUserTypeFactory(CassandraMappingContext.java:571)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataType(CassandraMappingContext.java:536)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getCodec(MappingCassandraConverter.java:151)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.writeUDTValue(MappingCassandraConverter.java:657)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:391)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getWriteValue(MappingCassandraConverter.java:822)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getWriteValue(MappingCassandraConverter.java:749)
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)

在调试时我发现了这个

suppressedExceptions    Collections$UnmodifiableRandomAccessList<E>  (id=317)   

以下是Java中的实体类

@Column("productsinfo")
@CassandraType(type = DataType.Name.UDT, userTypeName = "productsinfo")
private ProductsInfo productsInfo;

@Column("owned_product_details")
@CassandraType(type = DataType.Name.MAP, typeArguments =  DataType.Name.TEXT, DataType.Name.LIST )
private Map<String, List<ProductDetails>> ownedProductDetails;

@Column("available_product_details")
@CassandraType(type = DataType.Name.MAP, typeArguments =  DataType.Name.TEXT, DataType.Name.LIST )
private Map<String, List<ProductDetails>> availableProductDetails;

【问题讨论】:

【参考方案1】:

https://jira.spring.io/browse/DATACASS-651 解决了这个问题,你可以在更新到某个版本 >=2.2 RC1 后重试吗?

【讨论】:

以上是关于Collections$UnmodifiableRandomAccessList<E> Cassandra Frozen Map的主要内容,如果未能解决你的问题,请参考以下文章

为啥 collections.Counter 大写而 collections.defaultdict 不是?

[ Collections 学习02 ] collections - 2017.1.6

升序 Collections.sort(list) 降序 Collections.reserve(list) 随机 Collections.shuffle(list)

Collections笔记

Collections类er

参数 1:无法从 'System.Collections.Generic.List' 转换为 'System.Collections.Generic.List'