由以下原因引起:javax.persistence.PersistenceException:org.apache.cassandra.serializers.MarshalException:映射值后出现意外的无关字节
Caused by: javax.persistence.PersistenceException: org.apache.cassandra.serializers.MarshalException: Unexpected extraneous bytes after map value
我在 cassandra 中有一个 table,它有一列 MAP 类型(即)source_id_map map
当我尝试从此 table 读取一行时,我发现在读取地图类型的列时出现了一些问题,如下所示
Caused by: javax.persistence.PersistenceException:
org.apache.cassandra.serializers.MarshalException: Unexpected
extraneous bytes after map value
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2526)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653)
我注意到的另一个例外情况如下。
Error while retrieving fieldUTF8Type value via CQL, Caused by: .
java.lang.IllegalArgumentException
at java.nio.Buffer.limit(Buffer.java:267)
at org.apache.cassandra.utils.ByteBufferUtil.readBytes(ByteBufferUtil.java:543)
at org.apache.cassandra.utils.ByteBufferUtil.readBytesWithShortLength(ByteBufferUtil.java:552)
at org.apache.cassandra.serializers.CollectionSerializer.readValue(CollectionSerializer.java:128)
at org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:104)
at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator$MapTypeBuilder.decompose(CassandraDataTranslator.java:1177)
at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator$MapTypeBuilder.access00(CassandraDataTranslator.java:1100)
at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator.decompose(CassandraDataTranslator.java:507)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2518)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054)
at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653)
at com.impetus.client.cassandra.CassandraClientBase$CQLClient.executeQuery(CassandraClientBase.java:2272)
at com.impetus.client.cassandra.CassandraClientBase.executeSelectQuery(CassandraClientBase.java:926)
at com.impetus.client.cassandra.thrift.ThriftClient.executeQuery(ThriftClient.java:1062)
at com.impetus.client.cassandra.query.CassQuery.populateEntities(CassQuery.java:153)
at com.impetus.kundera.query.QueryImpl.fetch(QueryImpl.java:1377)
at com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:200)
请在插入和读取数据时启用 CQL3
Map propertyMap = new HashMap();
propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra-pu",propertyMap);
我在 cassandra 中有一个 table,它有一列 MAP 类型(即)source_id_map map
当我尝试从此 table 读取一行时,我发现在读取地图类型的列时出现了一些问题,如下所示
Caused by: javax.persistence.PersistenceException: org.apache.cassandra.serializers.MarshalException: Unexpected extraneous bytes after map value at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2526) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653)
我注意到的另一个例外情况如下。
Error while retrieving fieldUTF8Type value via CQL, Caused by: . java.lang.IllegalArgumentException at java.nio.Buffer.limit(Buffer.java:267) at org.apache.cassandra.utils.ByteBufferUtil.readBytes(ByteBufferUtil.java:543) at org.apache.cassandra.utils.ByteBufferUtil.readBytesWithShortLength(ByteBufferUtil.java:552) at org.apache.cassandra.serializers.CollectionSerializer.readValue(CollectionSerializer.java:128) at org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:104) at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator$MapTypeBuilder.decompose(CassandraDataTranslator.java:1177) at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator$MapTypeBuilder.access00(CassandraDataTranslator.java:1100) at com.impetus.client.cassandra.schemamanager.CassandraDataTranslator.decompose(CassandraDataTranslator.java:507) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2518) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054) at com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653) at com.impetus.client.cassandra.CassandraClientBase$CQLClient.executeQuery(CassandraClientBase.java:2272) at com.impetus.client.cassandra.CassandraClientBase.executeSelectQuery(CassandraClientBase.java:926) at com.impetus.client.cassandra.thrift.ThriftClient.executeQuery(ThriftClient.java:1062) at com.impetus.client.cassandra.query.CassQuery.populateEntities(CassQuery.java:153) at com.impetus.kundera.query.QueryImpl.fetch(QueryImpl.java:1377) at com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:200)
请在插入和读取数据时启用 CQL3
Map propertyMap = new HashMap();
propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra-pu",propertyMap);