(Available since v1.1)
Interprets the value being assigned to the property as a primary key, and fetches the corresponding entity from the underlying data store. This annotation requires that the type of the property it annotates be declared with an @Entity attribute.
Javadoc Ref :
@IsEntity
Input Types 1 |
Any |
Output Types |
Same as input |
1Automatic conversion will take place if the provided input does not match any of the input classes, as described in the conversions part of the manual.
ifNotFound |
What to do if the value is not found. Can be any of the following:
The default behaviour is ADD_ERROR, meaning that if the value is not found, a validation error will be logged in the error map. |
message |
Literal message to use if validation fails. |
errorCode |
Error code to use if validation fails. |
messageKey |
Message key to use if validation fails. |
@Entity
public class Country {
...
}
...
public class Customer {
@IsEntity(ifNotFound=NotFoundPolicy.ASSIGN_NULL)
private Country countryNull;
}
With this setup, when you later assign (using Shell.assign) the value "us" to the Country property, the system instead will use the configured EntityManager to retrieve the Country object whose primary key is "us". The EntityManager to use can be configured using either the @DBAware annotation or the @JPAAware annotation.