Hope I am reading the docs well: http://docs.datastax.com/en/developer/java-driver/3.0/java-driver/reference/crudOperations.html.
The Enumerated annotation
If your class contains an enum type field, you use the Enumerated annotation.
I have a Java enum and I want to use the @Enumerated annotation, but I can't seem to find it in 3.0.0 version of the driver, it was present in 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 =====
Has this changed in the new release? If yes, the docs should probably be updated too.
It does seem to be gone from the sources: https://github.com/datastax/java-driver/tree/3.0/driver-mapping/src/main/java/com/datastax/driver/mapping/annotations
It looks like support for @Enumerated has been removed. Now, enums support is provided by the codecs in drivers-extras. Check out these two tickets for addtional info: JAVA-605 and JAVA-846.
An example of what your enums code might look like is:
[Use]
EnumOrdinalCodec
andEnumNameCodec
: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; ... }
We are in the process of fixing the documentation.