You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today's @PrimaryKey, @Id and @PrimaryKeyColumn lead to ambiguity which types to use.
@Id: applied on field/property level to mark the primary key/identified
@PrimaryKey: similar to @Id but with column name property
@PrimaryKeyColumn: column name, ordering and primary key type properties
A typical compound key entity looks like:
@PrimaryKeyClass
class PersonKey {
@PrimaryKeyColumn(name="first_name", type=PARTITIONED, ordinal = 1) String firstname;
@PrimaryKeyColumn(type=CLUSTERED, ordinal = 2) String lastname;
}
@Table
class Person {
@PrimaryKey PersonKey key;
@Column("fieldname") String fieldname;
}
or
@Table
class Person {
@Id PersonKey key;
@Column("fieldname") String fieldname;
}
and a simple key entity:
@Table
class Person {
@PrimaryKey String key;
@Column("fieldname") String fieldname;
}
or
@Table
class Person {
@Id String key;
@Column("fieldname") String fieldname;
}
The code raises following questions:
When to use @Id and when @PrimaryKey?
Why is it that @Column cannot be applied to @Id properties?
PrimaryKeyColumn declares properties that can be left empty, depending on the primary key type
Are all annotations required?
Proposal
Deprecate @PrimaryKeyColumn in favor of @PartitionKey(value [optional, ordinal]) and @ClusteringKey(value [optional, ordinal], ordering) that can be combined with @Column. @PrimaryKeyColumn support can remain active and the new annotations can be built as composed annotations
Deprecate @PrimaryKey in favor of @Id that can be combined with @Column.
Mark Paluch opened DATACASS-361 and commented
Today's
@PrimaryKey
,@Id
and@PrimaryKeyColumn
lead to ambiguity which types to use.@Id
: applied on field/property level to mark the primary key/identified@PrimaryKey
: similar to@Id
but with column name property@PrimaryKeyColumn
: column name, ordering and primary key type propertiesA typical compound key entity looks like:
and a simple key entity:
The code raises following questions:
@Id
and when@PrimaryKey
?@Column
cannot be applied to@Id
properties?PrimaryKeyColumn
declares properties that can be left empty, depending on the primary key typeProposal
@PrimaryKeyColumn
in favor of@PartitionKey(value [optional, ordinal])
and@ClusteringKey(value [optional, ordinal], ordering)
that can be combined with@Column
.@PrimaryKeyColumn
support can remain active and the new annotations can be built as composed annotations@PrimaryKey
in favor of@Id
that can be combined with@Column
.No further details from DATACASS-361
The text was updated successfully, but these errors were encountered: