Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor primary key annotations [DATACASS-361] #530

Open
spring-projects-issues opened this issue Nov 29, 2016 · 1 comment
Open

Refactor primary key annotations [DATACASS-361] #530

spring-projects-issues opened this issue Nov 29, 2016 · 1 comment
Assignees
Labels
in: mapping Mapping and conversion infrastructure type: task A general task

Comments

@spring-projects-issues
Copy link

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 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:

  1. When to use @Id and when @PrimaryKey?
  2. Why is it that @Column cannot be applied to @Id properties?
  3. PrimaryKeyColumn declares properties that can be left empty, depending on the primary key type
  4. Are all annotations required?

Proposal

  1. 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
  2. Deprecate @PrimaryKey in favor of @Id that can be combined with @Column.

No further details from DATACASS-361

@spring-projects-issues
Copy link
Author

Mark Paluch commented

Oliver Drotbohm, John Blum thoughts?

@spring-projects-issues spring-projects-issues added in: mapping Mapping and conversion infrastructure type: task A general task labels Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping Mapping and conversion infrastructure type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants