引起:javax.persistence.PersistenceException:org.apache.cassandra.serializers.MarshalException:映射值后出现意外的无关字节

时间:2016-03-07 05:22:21

标签: java cassandra kundera

我在cassandra有一个表格,其中有一个MAP类型的列(即)source_id_map map

当我尝试从此表中读取一行时,我发现读取地图类型列时存在一些问题

  

引起:javax.persistence.PersistenceException:   org.apache.cassandra.serializers.MarshalException:意外   map值后的无关字节           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2526)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653)

我注意到的另一个例外情况如下。

  

通过CQL检索fieldUTF8Type值时出错,原因如下:。   java.lang.IllegalArgumentException异常           at java.nio.Buffer.limit(Buffer.java:267)           在org.apache.cassandra.utils.ByteBufferUtil.readBytes(ByteBufferUtil.java:543)           at org.apache.cassandra.utils.ByteBufferUtil.readBytesWithShortLength(ByteBufferUtil.java:552)           在org.apache.cassandra.serializers.CollectionSerializer.readValue(CollectionSerializer.java:128)           在org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:104)           在com.impetus.client.cassandra.schemamanager.CassandraDataTranslator $ MapTypeBuilder.decompose(CassandraDataTranslator.java:1177)           在com.impetus.client.cassandra.schemamanager.CassandraDataTranslator $ MapTypeBuilder.access $ 4800(CassandraDataTranslator.java:1100)           在com.impetus.client.cassandra.schemamanager.CassandraDataTranslator.decompose(CassandraDataTranslator.java:507)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setCollectionValue(CassandraDataHandlerBase.java:2518)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.setFieldValueViaCQL(CassandraDataHandlerBase.java:1504)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateViaThrift(CassandraDataHandlerBase.java:1163)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.onColumn(CassandraDataHandlerBase.java:1054)           在com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase.populateEntity(CassandraDataHandlerBase.java:653)           在com.impetus.client.cassandra.CassandraClientBase $ CQLClient.executeQuery(CassandraClientBase.java:2272)           在com.impetus.client.cassandra.CassandraClientBase.executeSelectQuery(CassandraClientBase.java:926)           在com.impetus.client.cassandra.thrift.ThriftClient.executeQuery(ThriftClient.java:1062)           在com.impetus.client.cassandra.query.CassQuery.populateEntities(CassQuery.java:153)           在com.impetus.kundera.query.QueryImpl.fetch(QueryImpl.java:1377)           在com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:200)

1 个答案:

答案 0 :(得分:1)

请在插入和读取数据时启用CQL3

Map propertyMap = new HashMap();
propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra-pu",propertyMap);