primaryKey
Creates a new
Entity.Key instance of the given entityType, initialised with the given value
Entities entities = domain.entities();
// Create a single-value primary key
Entity.Key customerKey = entities.primaryKey(Customer.TYPE, 42);
// Use the key to fetch an entity
Entity customer = connection.selectSingle(customerKey);
// Keys can be compared
Entity.Key anotherKey = entities.primaryKey(Customer.TYPE, 42);
customerKey.equals(anotherKey); // true
// Null values are allowed
Entity.Key nullKey = entities.primaryKey(Customer.TYPE, null);
- Type Parameters:
T- the key value type- Parameters:
entityType- the entityTypevalue- the key value, assumes a single value key- Returns:
- a new
Entity.Keyinstance - Throws:
IllegalStateException- in case the given primary key is a composite keyIllegalArgumentException- in case the value is not of the correct typeNullPointerException- in case entityType is null