2016-01-25 102 views
0

在我的cassandra(V 3.0.1)架構中,我有一個包含地圖類型的列。 柱-FAMILY:Kundera Cassandra - 映射地圖

CREATE TABLE test.Test (
    id uuid, 
    targetMisc map<text, double>, 
    PRIMARY KEY (id)); 

我用昆德拉(V3.2)與com.impetus.client.cassandra.thrift.ThriftClientFactory和我的測試實體看起來是這樣的:

@Entity 
@Table(name="test") 
public class Test implements Serializable { 

    private static final long serialVersionUID = -7665632851374123059L; 

    @Id 
    @Column 
    private UUID id; 


    @Column(name="targetmisc") 
    private Map<String, BigDecimal> targetMisc; 

} 

當我想通過查詢從測試表中的數據

EntityManager manager = entityManagerFactory.createEntityManager(getProperties()); 
result = new manager.find(Test.class, id); 

我收到映射無法映射的錯誤。

堆棧跟蹤:

16:26:34.165 [http-bio-8080-exec-3] ERROR e5bc0aec-802b-459f-a24e-675037811135 com.impetus.client.cassandra.datahandler.CassandraDataHandlerBase - Error while setting fieldtargetMisc value via CQL, Caused by: 
org.apache.cassandra.serializers.MarshalException: Unexpected extraneous bytes after map value 
at org.apache.cassandra.serializers.MapSerializer.deserializeForNativeProtocol(MapSerializer.java:109) ~[cassandra-all-2.2.2.jar:2.2.2] 

有誰沒問題出在哪裏?我使用CQL版本3和沒有地圖列的其他實體正在工作。

+0

請參考http://stackoverflow.com/questions/35008702/kundera-compatibility-with -cassandra-3-0-1/35030357#35030357 –

回答

1

我找到了解決這個問題的方法。當使用Cassandra 2.2而不是3.0並將private Map<String, BigDecimal> targetMisc;更改爲private Map<String, Double> targetMisc;時,映射將正常工作。

它接縫那裏昆德拉3.2確實與Cassandra的版本3有問題。 Kundera使用cassandra-driver-core-2.1.5.jar並且參考http://docs.datastax.com/en/developer/driver-matrix/doc/common/driverMatrix.html?scroll=driverMatrix__driver-cmpt-matrix,這個版本的java驅動程序沒有兼容性。

編輯:這裏(Kundera compatibility with Cassandra 3.0.1),你可以看到昆德拉2.2沒有一個完全支持卡桑德拉3. *