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
The use of the entity as id is type-safe and possible for certain cases, but using the entity as it's identifier is not very common. MapId is a flexible way to specify id's, but it's not type-safe and error prone at the time of writing.
Using entities with composite Id's declared inside the entity with a dedicated Id class would benefit from type safety and a more clear usage guiding the user. A declaration could look like:
public class TypeWithCompositeKeyIdClass {
private String firstname;
private String lastname;
}
@PrimaryKeyClass(TypeWithCompositeKeyIdClass.class)
public class TypeWithCompositeKey {
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1)
private String firstname;
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2)
private String lastname;
}
The annotation @PrimaryKeyClass(TypeWithCompositeKeyIdClass.class) is added to the entity class itself referencing the Id class that can be used for Id-based operations. On startup, the mapping context will verify that the Id class fits the entity by verifying types and names of the properties. This validation consolidates the validation to the startup. Using the id class in the code provides type safety and property name safety to the user
Mark Paluch opened DATACASS-324 and commented
Entities with a composite key inside the entity class require using
MapId
as Id or the entity itself when invoking operations with a given id:The use of the entity as id is type-safe and possible for certain cases, but using the entity as it's identifier is not very common.
MapId
is a flexible way to specify id's, but it's not type-safe and error prone at the time of writing.Using entities with composite Id's declared inside the entity with a dedicated Id class would benefit from type safety and a more clear usage guiding the user. A declaration could look like:
The annotation
@PrimaryKeyClass(TypeWithCompositeKeyIdClass.class)
is added to the entity class itself referencing the Id class that can be used for Id-based operations. On startup, the mapping context will verify that the Id class fits the entity by verifying types and names of the properties. This validation consolidates the validation to the startup. Using the id class in the code provides type safety and property name safety to the userNo further details from DATACASS-324
The text was updated successfully, but these errors were encountered: