CassandraSimpleTypeHolder's static block initializes Cassandra/Java type mappings by iterating over the value returned by Cassandra's DataType.allPrimitiveTypes(). The order in which DataType instances are returned is not guaranteed, and, further, multiple Cassandra types map to a single Java type.
Cassandra types ASCII, VARCHAR & TEXT map to java.lang.String; BIGINT & COUNTER map to java.lang.Long; BLOB & CUSTOM map to java.nio.ByteBuffer; UUID & TIMEUUID map to java.util.UUID.
This means that if, during schema generation, the generator encounters a Java type that maps to multiple C* types (String, Long, ByteBuffer, or UUID), the generator can't know the C* type that should be used; it must be told.
We'll consider adding an attribute ??? dataType() default ??? with an appropriate default to the @Column annotation so that developers can disambiguate the C* type to be used. We can't use DataType.Name for the attribute's type since there's no enum value meaning "no type".
If schema generation is not being used, then this issue is moot, provided that the Java type of the property is mapped appropriately to the target column's type by the DataStax driver
String and Long/long types were tied to a specific type. String property map to text column type and long properties map to bigint. These changes were part of DATACASS-280 and DATACASS-271.
Users can specify the column type with @CassandraType(type = …) to override defaults.
We should inspect ByteBuffer and UUID (currently maps to timeuuid by default) types whether they should map to different Cassandra types by default
Matthew T. Adams opened DATACASS-128 and commented
CassandraSimpleTypeHolder
's static block initializes Cassandra/Java type mappings by iterating over the value returned by Cassandra'sDataType.allPrimitiveTypes()
. The order in whichDataType
instances are returned is not guaranteed, and, further, multiple Cassandra types map to a single Java type.Cassandra types
ASCII
,VARCHAR
&TEXT
map tojava.lang.String
;BIGINT
&COUNTER
map tojava.lang.Long
;BLOB
&CUSTOM
map tojava.nio.ByteBuffer
;UUID
&TIMEUUID
map tojava.util.UUID
.This means that if, during schema generation, the generator encounters a Java type that maps to multiple C* types (
String
,Long
,ByteBuffer
, orUUID
), the generator can't know the C* type that should be used; it must be told.We'll consider adding an attribute
??? dataType() default ???
with an appropriate default to the@Column
annotation so that developers can disambiguate the C* type to be used. We can't useDataType.Name
for the attribute's type since there's no enum value meaning "no type".If schema generation is not being used, then this issue is moot, provided that the Java type of the property is mapped appropriately to the target column's type by the DataStax driver
Affects: 1.0 M1 (Dijkstra), 1.0 RC1 (Dijkstra)
Issue Links:
DATACASS-271 Upgrade to Cassandra 3.0.0
DATACASS-285 Add support for counter columns
DATACASS-280 Refactor Cassandra query execution and mapping to consolidate mapping
DATACASS-83 Support custom field mappings
DATACASS-375 UUID should map to Cassandra's uuid type and not timeuuid
Referenced from: commits 183c502
The text was updated successfully, but these errors were encountered: