public interface RecordTemplate<T extends net.java.ao.RawEntity<?>>
DAOCache
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the record template, so it can be reused for another record.
|
T |
create()
Convenience method to call
DAOCache.create(com.playsql.utils.activeobjects.cache.RecordTemplate<T>)
But realistically, if you are using the DAOCache , you rather want to call createOrUpdate() . |
T |
createOrUpdate()
Convenience method to call
DAOCache.createOrUpdate(com.playsql.utils.activeobjects.cache.RecordTemplate<T>) |
T |
fieldsToOverride()
Use this method to set the fields which must be written in all cases when calling create() or update().
|
T |
fieldsToWriteIfNull()
Use this method to set the fields (other than primary key) that must be written in the DB if
the previous value is null.
|
Predicate<T> |
getRecordMatcher()
Returns a predicate that can tell whether any record perfectly matches this template.
|
Map<String,Object> |
getTableFields()
Return the list of field names (the column names in Active Objects) and values, in preparation for an AO Query.
|
T |
searchFirst()
Convenience method to call
DAOCache.searchFirst(com.playsql.utils.activeobjects.cache.RecordTemplate<T>) |
boolean |
setAll(T target,
boolean checkValuesBeforeSetting)
Assigns all values of this template to the 'target'.
|
void |
setFieldsIfNull(Consumer<T> callback)
Use this method to set the "write" fields, i.e.
|
void |
setFieldsOverwrite(Consumer<T> callback)
Use this method to set the "write" fields, i.e.
|
void |
setPrimaryKey(Consumer<T> callback)
Use this method to set the primary key of the record - Those fields will be used in the queries for example.
|
void clear()
boolean setAll(T target, boolean checkValuesBeforeSetting)
checkValuesBeforeSetting
- if true, then we will call the getters to compare the value with what needs
to be saved, before saving. If false, we'll call the setters straight away.Predicate<T> getRecordMatcher()
void setPrimaryKey(Consumer<T> callback)
T fieldsToWriteIfNull()
T fieldsToOverride()
void setFieldsIfNull(Consumer<T> callback)
create()
.
Note that booleans cannot be set using this method, because they are always considered to be 'false'
if null.
Don't forget to call createOrUpdate()
or create()
afterwards ;)void setFieldsOverwrite(Consumer<T> callback)
createOrUpdate()
or create()
afterwards ;)Map<String,Object> getTableFields()
T searchFirst()
DAOCache.searchFirst(com.playsql.utils.activeobjects.cache.RecordTemplate<T>)
T createOrUpdate()
DAOCache.createOrUpdate(com.playsql.utils.activeobjects.cache.RecordTemplate<T>)
T create()
DAOCache.create(com.playsql.utils.activeobjects.cache.RecordTemplate<T>)
But realistically, if you are using the DAOCache
, you rather want to call createOrUpdate()
.Copyright © 2022 Requirement Yogi. All rights reserved.