Datastax java driver 3.0.0未找到枚举注释

时间:2016-02-01 14:09:47

标签: java enums cassandra datastax-java-driver

希望我正在阅读文档: http://docs.datastax.com/en/developer/java-driver/3.0/java-driver/reference/crudOperations.html

  

枚举注释

     

如果您的类包含枚举类型字段,则使用枚举注释。

我有一个Java枚举,我想使用@Enumerated注释,但我似乎无法在3.0.0版本的驱动程序中找到它,它存在于2.1.9中。

$ find . -type f -name \*.jar|while read i; do echo ====== $i =====; jar -tf $i|grep Enumerated; done
====== ./cassandra-driver-core/2.1.4/cassandra-driver-core-2.1.4-javadoc.jar =====
====== ./cassandra-driver-core/2.1.4/cassandra-driver-core-2.1.4-sources.jar =====
====== ./cassandra-driver-core/2.1.4/cassandra-driver-core-2.1.4.jar =====
====== ./cassandra-driver-core/2.1.5/cassandra-driver-core-2.1.5.jar =====
====== ./cassandra-driver-core/2.1.7.1/cassandra-driver-core-2.1.7.1.jar =====
====== ./cassandra-driver-core/2.1.9/cassandra-driver-core-2.1.9.jar =====
====== ./cassandra-driver-core/3.0.0/cassandra-driver-core-3.0.0-sources.jar =====
====== ./cassandra-driver-core/3.0.0/cassandra-driver-core-3.0.0.jar =====
====== ./cassandra-driver-dse/2.1.5/cassandra-driver-dse-2.1.5.jar =====
====== ./cassandra-driver-extras/3.0.0/cassandra-driver-extras-3.0.0.jar =====
====== ./cassandra-driver-mapping/2.1.4/cassandra-driver-mapping-2.1.4-javadoc.jar =====
com/datastax/driver/mapping/annotations/class-use/Enumerated.html
com/datastax/driver/mapping/annotations/Enumerated.html
====== ./cassandra-driver-mapping/2.1.4/cassandra-driver-mapping-2.1.4-sources.jar =====
com/datastax/driver/mapping/annotations/Enumerated.java
====== ./cassandra-driver-mapping/2.1.4/cassandra-driver-mapping-2.1.4.jar =====
com/datastax/driver/mapping/annotations/Enumerated.class
====== ./cassandra-driver-mapping/2.1.7.1/cassandra-driver-mapping-2.1.7.1.jar =====
com/datastax/driver/mapping/annotations/Enumerated.class
====== ./cassandra-driver-mapping/2.1.9/cassandra-driver-mapping-2.1.9.jar =====
com/datastax/driver/mapping/annotations/Enumerated.class
====== ./cassandra-driver-mapping/3.0.0/cassandra-driver-mapping-3.0.0-sources.jar =====
====== ./cassandra-driver-mapping/3.0.0/cassandra-driver-mapping-3.0.0.jar =====

新版本中有没有改变?如果是,那么文档也应该更新。

它似乎已从消息来源消失:https://github.com/datastax/java-driver/tree/3.0/driver-mapping/src/main/java/com/datastax/driver/mapping/annotations

1 个答案:

答案 0 :(得分:3)

看起来已删除对@Enumerated的支持。现在,enums支持由驱动程序附加内容中的编解码器提供。查看这两张附加信息的门票:JAVA-605JAVA-846

您的枚举代码的example代码如下:

  

[使用] EnumOrdinalCodecEnumNameCodec

 java    
 enum Foo {...}
 enum Bar {...}

 // register the appropriate codecs
 CodecRegistry.DEFAULT_INSTANCE
     .register(new EnumOrdinalCodec<Foo>(Foo.class))
     .register(new EnumNameCodec<Bar>(Bar.class))

 // the following mappings are handled out-of-the-box
 @Table
 public class MyPojo {
     private Foo foo;
     private List<Bar> bars;
     ...
 }

我们正在修复文档。