我在Cassandra表發生更改後在C#中遇到了問題。原始主鍵包含2個部分((person_id),car_id),這不足以識別單個行,因此密鑰得到擴展((person_id),car_id,purchase_date)。C#cassandra複合主鍵
爲person_id(BIGINT), car_id(BIGINT), PURCHASE_DATE(timeuuid)
這種變化之後,我的一些Java錯誤
2016年1月4日14:24: 42.2935 | ERROR | MyModule的|錯誤而做的工作了java.lang.RuntimeException:無法在org.apache.cassandra.db.marshal.CompositeType得到比較2(org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra .db.marshal.TimeUUIDType),org.apache.cassandra.db.marshal.UTF8Type)。這可能是由於模式之間的不匹配和數據讀取
我使用的datastax 2.7.0.0和我查詢我檢索所有記錄人:
this.storage.GetEntityList<MyEntity>(r => r.PersonId== personid);
public virtual IEnumerable<T> GetEntityList<T>(Expression<Func<T, bool>> predicate)
{
return new Table<T>(this.Session)
.Where(predicate)
.Execute();
}
public class MyEntity
{
[PartitionKey]
[Column("person_id")]
public long PersonId{ get; set; }
[ClusteringKey]
[Column("car_id")]
public long CarId{ get; set; }
[ClusteringKey(1)]
[Column("purchase_date")]
public TimeUuid PurchaseDate{ get; set; }
OFC如果我用SimpleStatement用cql查詢數據庫,而不是像魅力(ironi)那樣工作,但我無所謂。我想知道爲什麼我的解決方案失敗。
我發現很難將您的答案與我的問題聯繫起來,這隻會對響應進行排序。 – codealot
我不確定我的答案能解決您的問題。但我所知道的是,同一分區中的條目是自然排序的。在Java異常中提到了一個ReversedType。我想這意味着purchase_date按降序排列。 – DineMartine
另外,我修復了PurchaseDate屬性的類型。 – DineMartine