2015-11-04 49 views
2

我想有彈簧的數據我的枚舉類型轉換爲和INT場卡桑德拉,但我發現以下異常:彈簧數據卡桑德拉無法枚舉轉換

Unexpected runtime exception java.lang.IllegalArgumentException: 
Value 2 of type class com.twc.atg.td.dbo.client.ClassCode does not correspond to any CQL3 type 

這裏是這段代碼我使用:

@Enumerated(EnumType.ORDINAL) 
@Column("class_code") 
public ClassCode classCode; 
+0

哪個類拋出了這個異常?你可以添加更多的細節來堆棧跟蹤。 – jny

+0

你有沒有找到解決方案? – Vagif

+0

任何解決方案?遇到同樣的問題 – Matt

回答

0

因爲它不是由彈簧數據卡桑德拉支持,可以實現在getter/setter方法這個邏輯。

@Table 
public class Writer { 
    ... 
    public enum WriterType { 
     POET, DETECTIVE, JOUNALIST 
    } 

    ... 
    @Column(value = "writer_type") 
    private Integer writerType; 

    ... 
    public WriterType getWriterType() { 
     return WriterType.values()[writerType]; 
    } 

    public void setWriterType(WriterType writerType) { 
     this.writerType = writerType.ordinal(); 
    }