T
- the domain model type the repository managespublic interface Repository<T extends Model>
Modifier and Type | Method and Description |
---|---|
Query<T> |
all()
Get the
Query instance of the managed domain class. |
T |
copy(T entity,
boolean deep)
Create a duplicate copy of the given entity.
In case of deep copy, one-to-many records are duplicated. |
T |
create(Map<String,Object> values)
Create a new instance of the domain model with the given default values.
|
List<Property> |
fields()
Return list of properties on the domain model managed by this repository.
|
T |
find(Long id)
Find by primary key.
|
void |
flush()
Synchronize the persistence context to the underlying database.
|
Map<String,Object> |
populate(Map<String,Object> json,
Map<String,Object> context)
Populate the given json map with additional data.
|
void |
refresh(T entity)
Refresh the state of the instance from the database, overwriting changes made to the entity, if
any.
|
void |
remove(T entity)
Remove the given entity.
|
T |
save(T entity)
Save the given entity.
|
Map<String,Object> |
validate(Map<String,Object> json,
Map<String,Object> context)
Validate the given json map before persisting.
|
List<Property> fields()
Property
T create(Map<String,Object> values)
values
- the default valuesT copy(T entity, boolean deep)
entity
- the entity bean to copydeep
- whether to create a deep copyT find(Long id)
id
- the record idT save(T entity)
Depending on the implementation, it may return same entity or a copy of it. For example JPA implementation may return a copy if the given entity can't be managed.
entity
- the entity object to savevoid remove(T entity)
entity
- the entity objectvoid refresh(T entity)
entity
- the entity object to refreshvoid flush()
Map<String,Object> validate(Map<String,Object> json, Map<String,Object> context)
This method is called before the json map is converted to model object.
json
- the json map to validatecontext
- the contextMap<String,Object> populate(Map<String,Object> json, Map<String,Object> context)
This method is called before returning the json data as response.
json
- the json map to populatecontext
- the context