T - public class PartialStash<T extends Model> extends Stash<T>
| Modifier and Type | Field and Description |
|---|---|
protected List<Col> |
columns |
protected Map<Long,T> |
itemByPrimaryKey |
protected List<T> |
items |
protected Map<String,Map<Object,T>> |
keyNameToUniqueKeyToValue |
protected Set<String> |
uniqueFields |
| Constructor and Description |
|---|
PartialStash() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cloneInto(Object source,
Object dest,
Iterable<String> properties,
Boolean copyNulls,
List<String> changedKeyFields)
Clones all non-null values from "source" into "dest"
|
int |
countForKey(String keyName,
Object value)
Count the number of objects associated with an alternative key
|
T |
detach(T obj)
Return a cloned version of the object.
|
FilterChain<T> |
filterByKey(String key,
Object lookupValue)
Create a new filterChain, restricting it to items matching the lookupValue for the key
|
FilterChain<T> |
filterChain()
Create a new FilterChain for this stash
|
FilterChain<T> |
filterChain(List<T> subset)
Create a new filter chain using a subset of items
|
T |
forId(Long id)
Get a cloned/detached object by id
|
T |
forUniqueKey(String keyName,
Object lookupValue)
Retrieve an object via unique key.
|
String |
getInitialLoadSql() |
List<T> |
getItems()
All the items in the stash.
|
void |
hardDelete(T obj)
Remove the object from the stash and the underlying data store
|
void |
init(DataAccessRegistration registration,
ModelController<T> controller,
Persister<T> persister)
Initialized the Stash with required attributes, this is
called via dataAccess registration.
|
List<T> |
listForKey(String keyName,
Object value)
Retrieve all objects for a given alternative key
|
void |
loadAll()
Load all items from the datastore into the stash.
|
void |
loadForId(Long id)
Load or reload the item with the given id from the datastore into the stash
|
boolean |
loadItem(T item)
Re-load the given object from the datastore into the stash
|
void |
onPreRead()
Called before any of the data access methods run
|
T |
originalForId(Long id)
Get the original object by id, if modified, the object in the stash
will be modified, so be careful.
|
protected void |
preRegisterItem(T item)
This gets called before persist, to avoid a race-condition whereby:
1) Thread A saves to the database
2) Thread B syncs from the database and loads the new object
3) Thread A finishes the database save, and then adds the newly saved item to the registry
4) Now we have two copies of the object in memory
|
protected void |
registerItem(T item) |
void |
registerKeys(T item) |
void |
reset()
Reset the cache, nulling out all existing fields, and then reloading everything from
the database.
|
void |
save(T obj)
Save the object to the stash and the underlying data store
|
void |
sync(T obj)
Take the passed in object, find the object in the stash with the same id, and
sync the data of the passed in object to the stashed object.
|
void |
syncForSave(T obj) |
getBucket, getController, getKeyFields, getPersister, getUniqueFields, reloadIfNewer, setKeyFields, setUniqueFieldsprotected Map<Long,T extends Model> itemByPrimaryKey
protected Set<String> uniqueFields
protected Map<String,Map<Object,T extends Model>> keyNameToUniqueKeyToValue
public PartialStash()
public void init(DataAccessRegistration registration, ModelController<T> controller, Persister<T> persister)
Stashpublic void sync(T obj)
Stashpublic boolean cloneInto(Object source, Object dest, Iterable<String> properties, Boolean copyNulls, List<String> changedKeyFields)
source - dest - properties - copyNulls - changedKeyFields - public T detach(T obj)
Stashpublic void save(T obj)
Stashpublic void syncForSave(T obj)
syncForSave in class Stash<T extends Model>public void hardDelete(T obj)
StashhardDelete in class Stash<T extends Model>public void loadAll()
Stashpublic String getInitialLoadSql()
public void loadForId(Long id)
Stashpublic boolean loadItem(T item)
Stashprotected void preRegisterItem(T item)
item - protected void registerItem(T item)
public void registerKeys(T item)
public void reset()
Stashpublic void onPreRead()
Stashpublic T forId(Long id)
Stashpublic T originalForId(Long id)
StashoriginalForId in class Stash<T extends Model>public T forUniqueKey(String keyName, Object lookupValue)
StashforUniqueKey in class Stash<T extends Model>public List<T> listForKey(String keyName, Object value)
StashlistForKey in class Stash<T extends Model>public int countForKey(String keyName, Object value)
StashcountForKey in class Stash<T extends Model>public FilterChain<T> filterChain()
StashfilterChain in class Stash<T extends Model>public FilterChain<T> filterByKey(String key, Object lookupValue)
StashfilterByKey in class Stash<T extends Model>key - - a model field that has been defined as a keypublic FilterChain<T> filterChain(List<T> subset)
StashfilterChain in class Stash<T extends Model>Copyright © 2016. All rights reserved.