|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Storage<S extends Storable>
Access for a specific type of Storable from a Repository.
Storage instances are mutable, but they are thread-safe.
| Method Summary | |
|---|---|
boolean |
addTrigger(Trigger<? super S> trigger)
Register a trigger which will be called for overridden methods in the given trigger implementation. |
Class<S> |
getStorableType()
Returns the specific type of Storable managed by this object. |
S |
prepare()
Prepares a new object for loading, inserting, updating, or deleting. |
Query<S> |
query()
Query for all Storable instances in this Storage. |
Query<S> |
query(Filter<S> filter)
Query for Storable instances against an explicitly constructed filter object. |
Query<S> |
query(String filter)
Query for Storable instances against a filter expression. |
boolean |
removeTrigger(Trigger<? super S> trigger)
Remove a trigger which was registered earlier. |
void |
truncate()
Attempts to quickly delete all Storables instances in this Storage. |
| Method Detail |
|---|
Class<S> getStorableType()
S prepare()
Query<S> query()
throws FetchException
FetchException - if storage layer throws an exceptionquery(String)
Query<S> query(String filter)
throws FetchException
"ID = ?". Filters can also contain several kinds of relational
operators, boolean logic operators, sub-properties, and parentheses. A
more complex example might be "income < ? | (name = ? & address.zipCode != ?)".
When querying for a single Storable instance by its primary key, it is
generally more efficient to call prepare(), set primary key
properties, and then call Storable.load(). For example, consider
an object with a primary key consisting only of the property "ID". It
can be queried as:
Storage<UserInfo> users;
UserInfo user = users.query("ID = ?").with(123456).loadOne();
The above code will likely open a Cursor in order to verify that just
one object was loaded. Instead, do this:
Storage<UserInfo> users; UserInfo user = users.prepare(); user.setID(123456); user.load();The complete syntax for query filters follows. Note that:
Filter = OrFilter
OrFilter = AndFilter { "|" AndFilter }
AndFilter = NotFilter { "&" NotFilter }
NotFilter = [ "!" ] EntityFilter
EntityFilter = PropertyFilter
= ChainedFilter
| "(" Filter ")"
PropertyFilter = ChainedProperty RelOp "?"
RelOp = "=" | "!=" | "<" | ">=" | ">" | "<="
ChainedFilter = ChainedProperty "(" [ Filter ] ")"
ChainedProperty = Identifier
| InnerJoin "." ChainedProperty
| OuterJoin "." ChainedProperty
InnerJoin = Identifier
OuterJoin = "(" Identifier ")"
filter - query filter expression
FetchException - if storage layer throws an exception
IllegalArgumentException - if filter is null
MalformedFilterException - if expression is malformed
UnsupportedOperationException - if given filter is unsupported by repository
Query<S> query(Filter<S> filter)
throws FetchException
filter - query filter
FetchException - if storage layer throws an exception
IllegalArgumentException - if filter is null
UnsupportedOperationException - if given filter is unsupported by repository
void truncate()
throws PersistException
If this Storage has any registered triggers which act on deletes, all
Storables are deleted via query().deleteAll() instead to ensure
these triggers get run.
PersistExceptionboolean addTrigger(Trigger<? super S> trigger)
IllegalArgumentException - if trigger is nullboolean removeTrigger(Trigger<? super S> trigger)
IllegalArgumentException - if trigger is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||