public interface Store extends RemoteStore
Many methods contain a condition string. The syntax of them is as in an SQL where clause like "name='john' and salary > 1000", where name and salary are database fields of the given object class. In methods where the extra parameter bindVars appears, the condition can contain placeholders, for example "name=? and salary > ?".
The condition parameter may always be null, as well as the order parameter. The bindVars may be null if no placeholders are used in the condition.
Modifier and Type | Method and Description |
---|---|
void |
checkUnique(Persistent o)
This method throws an
ApplicationException if a duplicate of the given object is in the database. |
int |
count(Class<?> c,
String cond,
Object... bindVars)
This method returns the number of members of a given class matching the given condition.
|
int |
count(String classname,
String cond,
Object... bindVars)
This method returns the number of members of a given class matching the given condition.
|
int |
delete(Class<?> c,
String condition,
Object... bindVars)
Deletes some objects from the database.
|
int |
delete(Collection<?> collection)
Deletes the objects of the collection from the database.
|
int |
delete(Persistent o)
Deletes the object from the database.
|
int |
delete(String classname,
String condition,
Object... bindVars)
Deletes some objects from the database.
|
int |
executeStatement(String stmt)
Execute a SQL statement.
|
int |
executeStatement(String stmt,
Object... bindVars)
Execute a SQL statement.
|
<P extends Persistent> |
fill(List<P> l)
Fills the objects within list l.
|
<P> P |
fill(P o)
Fill objects where only the oid is set.
|
<P extends Persistent,R extends Persistent> |
fillByField(Class<? extends P> c,
Collection<R> collection,
String fieldname)
Fill a heterogeneous set of Persistents referenced via a field of a collection of (persistent) objects.
|
<P extends Persistent,R extends Persistent> |
fillByField(Class<? extends P> c,
Collection<R> collection,
String fieldname,
String condition,
Object... bindVars)
Fill a heterogeneous set of Persistents referenced via a field of a collection of (persistent) objects.
|
<P extends Persistent> |
fillByFields(Collection<P> collection,
String fieldNames)
Fetches dependent objects of a collection of Persistents reachable via the specified fields.
|
<P> P |
get(Class<? extends P> c,
long oid)
Method for getting objects from the database.
|
<P> P |
get(Class<? extends P> c,
String cond)
Method for getting objects from the database.
|
<P> P |
get(Class<? extends P> c,
String cond,
Object... bindVars)
Method for getting objects from the database.
|
<P extends Persistent> |
get(String classname,
long oid)
Method for getting objects from the database.
|
<P extends Persistent> |
get(String classname,
String cond)
Method for getting objects from the database.
|
<P extends Persistent> |
get(String classname,
String cond,
Object... bindVars)
Method for getting objects from the database.
|
<P> P |
getNoCache(Class<? extends P> c,
long oid)
Method for getting objects directly from the database bypassing the object cache.
|
long |
getOID()
Return the next object id from the oid-factory in the database
|
String |
getSchema()
Returns the schema of the tables
|
TableModel |
getTable(String q,
Object... bindVars)
Deprecated.
|
TableModel |
getTable(String q,
Object[] bindVars,
int[] sqlTypes)
Returns the results of the given query.
|
Object |
getValue(int sqlType,
String stmt,
Object... bindVars)
Execute a SQL statement which returns one value.
|
Object |
getValue(String stmt)
Execute a SQL statement which returns one value.
|
Object |
getValue(String stmt,
int sqlType)
Deprecated.
|
Object |
getValue(String stmt,
Object... bindVars)
Execute a SQL statement which returns one value.
|
Object |
getValue(String stmt,
Object[] bindVars,
int sqlType)
Deprecated.
|
boolean |
hasRows(String stmt,
Object... bindVars)
Check whether the statement returns results.
|
boolean |
inDatabase(Persistent o)
Check whether the object is in database
|
void |
insert(Collection<?> collection)
Insert the objects of the collection into the database.
|
void |
insert(Persistent o)
Insert the object into the database.
|
<P> List<P> |
limitedList(Class<? extends P> c,
int maxRows,
int offset,
String cond,
String order,
Object... bindVars)
This method returns the members of the given class matching the given condition
and limiting the returned entry count.
|
<P> List<P> |
limitedList(Class<? extends P> c,
int maxRows,
String cond,
String order,
Object... bindVars)
This method returns the members of the given class matching the given condition
and limiting the returned entry count.
|
<P> List<P> |
list(Class<? extends P> c)
This method returns all members of the given class.
|
<P> List<P> |
list(Class<? extends P> c,
String cond)
This method returns the members of the given class matching the given condition.
|
<P> List<P> |
list(Class<? extends P> c,
String cond,
String order)
This method returns the members of the given class matching the given condition.
|
<P> List<P> |
list(Class<? extends P> c,
String cond,
String order,
Object... bindVars)
This method returns the members of the given class matching the given condition.
|
<P> List<P> |
list(Class<? extends P> c,
String cond,
String order,
Object[] bindVars,
int maxRows)
Deprecated.
|
<P> List<P> |
list(Class<? extends P> c,
String cond,
String order,
Object[] bindVars,
int maxRows,
int offset)
Deprecated.
|
<P extends Persistent> |
list(String classname)
This method returns all members of the given class.
|
<P extends Persistent> |
list(String classname,
String cond)
This method returns the members of the given class matching the given condition.
|
<P extends Persistent> |
list(String classname,
String cond,
String order)
This method returns the members of the given class matching the given condition.
|
<P extends Persistent> |
list(String classname,
String cond,
String order,
Object... bindVars)
This method returns the members of the given class matching the given condition.
|
<P> List<P> |
list2(Class<? extends P> c,
String q,
Object... bindVars)
This method returns the members of the given class matching the given condition.
|
<P extends Persistent> |
list2(String classname,
String q,
Object... bindVars)
This method returns the members of the given class matching the given condition.
|
<P> Set<P> |
setOf(Class<? extends P> c,
String cond,
Object... bindVars)
This method returns the members of the given class matching the given condition as a
Set . |
<P extends Persistent> |
setOf(String classname,
String cond,
Object... bindVars)
This method returns the members of the given class matching the given condition as a
Set . |
void |
setSchema(String schema)
Set the schema of the tables
|
<P> Map<Long,P> |
table(Class<? extends P> c,
String cond,
Object... bindVars)
This method returns the members of the given class matching the given condition as a
Map . |
<P extends Persistent> |
table(String classname,
String cond,
Object... bindVars)
This method returns the members of the given class matching the given condition as a
Map . |
int |
update(Collection<?> collection)
Updates the objects of the collection in the database.
|
int |
update(Persistent o)
Update the database tuple corresponding to the given object.
|
int |
update(Persistent o,
String... fieldNames)
Update some fields of the database tuple corresponding to the given object.
|
<P> List<P> list(Class<? extends P> c)
list
in interface RemoteStore
c
- the class of the objects<P extends Persistent> List<P> list(String classname)
list
in interface RemoteStore
classname
- the name of the class of the object<P> List<P> list(Class<? extends P> c, String cond)
list
in interface RemoteStore
c
- the class of the objectscond
- a SQL condition<P extends Persistent> List<P> list(String classname, String cond)
list
in interface RemoteStore
classname
- the name of the class of the objectcond
- a SQL condition<P> List<P> list(Class<? extends P> c, String cond, String order)
list
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.<P extends Persistent> List<P> list(String classname, String cond, String order)
list
in interface RemoteStore
classname
- the name of the class of the objectcond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.<P> List<P> list(Class<? extends P> c, String cond, String order, Object... bindVars)
list
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P> List<P> limitedList(Class<? extends P> c, int maxRows, String cond, String order, Object... bindVars)
Note that a unique order is not only strongly recommended; some DBMSs require an order by in this case. If an empty order is provided or when the order does not contain the oid column, OID is added as order column.
limitedList
in interface RemoteStore
c
- the class of the objectsmaxRows
- the maximum number of entries to returncond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables, this should contain the values@Deprecated <P> List<P> list(Class<? extends P> c, String cond, String order, Object[] bindVars, int maxRows)
limitedList(Class, int, String, String, Object...)
insteadNote that a unique order is not only strongly recommended; some DBMSs require an order by in this case. If an empty order is provided or when the order does not contain the oid column, OID is added as order column.
list
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesmaxRows
- the maximum number of entries to return<P> List<P> limitedList(Class<? extends P> c, int maxRows, int offset, String cond, String order, Object... bindVars)
Note that a unique order is not only strongly recommended; some DBMSs require an order by in this case. If an empty order is provided or when the order does not contain the oid column, OID is added as order column.
limitedList
in interface RemoteStore
c
- the class of the objectsmaxRows
- the maximum number of entries to returnoffset
- number of rows to skip from the beginningcond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables, this should contain the values@Deprecated <P> List<P> list(Class<? extends P> c, String cond, String order, Object[] bindVars, int maxRows, int offset)
limitedList(Class, int, int, String, String, Object...)
insteadNote that a unique order is not only strongly recommended; some DBMSs require an order by in this case. If an empty order is provided or when the order does not contain the oid column, OID is added as order column.
list
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesmaxRows
- the maximum number of entries to returnoffset
- number of rows to skip from the beginning<P extends Persistent> List<P> list(String classname, String cond, String order, Object... bindVars)
list
in interface RemoteStore
classname
- the name of the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.bindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P> List<P> list2(Class<? extends P> c, String q, Object... bindVars)
StoreUtil.dbAttrs(Persistent, String)
dbAttrs(String) method to construct the attribute list,
that is to formulate "select "+StoreUtil.dbAttrs(user,"u")+" from avw_user u, avw_userrole ur where..."list2
in interface RemoteStore
c
- the class of the objectsq
- a SQL querybindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P extends Persistent> List<P> list2(String classname, String q, Object... bindVars)
StoreUtil.dbAttrs(Persistent, String)
dbAttrs(String) method to construct the attribute list,
that is to formulate "select "+StoreUtil.dbAttrs(user,"u")+" from avw_user u, avw_userrole ur where..."list2
in interface RemoteStore
classname
- the name of the class of the objectsq
- a SQL querybindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P> Map<Long,P> table(Class<? extends P> c, String cond, Object... bindVars)
Map
.
The keys of the map are the oids of the objects as Long objects, the values are the objects itself.table
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P extends Persistent> Map<Long,P> table(String classname, String cond, Object... bindVars)
Map
.
The keys of the table are the oids of the objects as Long objects, the values are the objects itself.table
in interface RemoteStore
classname
- the name of the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P> Set<P> setOf(Class<? extends P> c, String cond, Object... bindVars)
Set
.
The the values are the objects itself.setOf
in interface RemoteStore
c
- the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P extends Persistent> Set<P> setOf(String classname, String cond, Object... bindVars)
Set
.
The keys of the table are the oids of the objects as Long objects, the values are the objects itself.setOf
in interface RemoteStore
classname
- the name of the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesint count(Class<?> c, String cond, Object... bindVars)
count
in interface RemoteStore
c
- the classcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesint count(String classname, String cond, Object... bindVars)
count
in interface RemoteStore
classname
- the name of the classcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesboolean inDatabase(Persistent o)
inDatabase
in interface RemoteStore
boolean hasRows(String stmt, Object... bindVars)
hasRows
in interface RemoteStore
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the values<P> P get(Class<? extends P> c, long oid)
get
in interface RemoteStore
c
- the class of the objectoid
- the oid of the object<P extends Persistent> P get(String classname, long oid)
get
in interface RemoteStore
classname
- the name of the class of the objectoid
- the oid of the object<P> P get(Class<? extends P> c, String cond)
get
in interface RemoteStore
c
- the class of the objectcond
- a SQL condition<P extends Persistent> P get(String classname, String cond)
get
in interface RemoteStore
classname
- the name of the class of the objectcond
- a SQL condition<P> P get(Class<? extends P> c, String cond, Object... bindVars)
get
in interface RemoteStore
c
- the class of the objectcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P extends Persistent> P get(String classname, String cond, Object... bindVars)
get
in interface RemoteStore
classname
- the name of the class of the objectcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values<P> P fill(P o)
fill
in interface RemoteStore
o
- the object<P extends Persistent> List<P> fill(List<P> l)
fill
in interface RemoteStore
l
- the list of objects to be filledvoid checkUnique(Persistent o)
RemoteStore
ApplicationException
if a duplicate of the given object is in the database.
It uses the key fields returned by method Persistent.getKeys()
of object o
for the comparison.checkUnique
in interface RemoteStore
o
- the object<P extends Persistent,R extends Persistent> Set<P> fillByField(Class<? extends P> c, Collection<R> collection, String fieldname)
fillByField
in interface RemoteStore
c
- (super)class of the referenced Objectscollection
- the Collection of referencing objects, must all be filled.fieldname
- the name of the referencing field. Must be a Persistent
.<P extends Persistent,R extends Persistent> Set<P> fillByField(Class<? extends P> c, Collection<R> collection, String fieldname, String condition, Object... bindVars)
fillByField
in interface RemoteStore
c
- (super)class of the referenced Objectscollection
- the Collection of referencing objects, must all be filled.fieldname
- the name of the referencing field. Must be a Persistent
.condition
- an optional SQL condition.bindVars
- optional array of parameter bindings for the SQL statement.<P extends Persistent> void fillByFields(Collection<P> collection, String fieldNames)
fillByFields
in interface RemoteStore
collection
- the Collection of referencing objects, must all be filled.fieldNames
- a comma separated string of field names. Every field name must denote a Persistent
field.void insert(Persistent o)
insert
in interface RemoteStore
o
- the objectvoid insert(Collection<?> collection)
insert
in interface RemoteStore
collection
- the objects to insert (all of the objects must implement Persistent)int update(Persistent o)
update
in interface RemoteStore
o
- the objectint update(Collection<?> collection)
update
in interface RemoteStore
collection
- the objects to update (all of the objects must implement Persistent)int update(Persistent o, String... fieldNames)
update
in interface RemoteStore
o
- the objectfieldNames
- an array containing the names of the fields which should be updatedint delete(Persistent o)
delete
in interface RemoteStore
o
- the object to deleteint delete(Collection<?> collection)
delete
in interface RemoteStore
collection
- the objects to delete (all of the objects must implement Persistent)int delete(Class<?> c, String condition, Object... bindVars)
Persistent.beforeDelete()
nor PersistentEventHandler.beforeDelete(Persistent)
methods
are called for the individual deleted objects.delete
in interface RemoteStore
c
- the class of the objectscondition
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesint delete(String classname, String condition, Object... bindVars)
Persistent.beforeDelete()
nor PersistentEventHandler.beforeDelete(Persistent)
methods
are called for the individual deleted objects.delete
in interface RemoteStore
classname
- the name of the class of the objectscondition
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the valuesint executeStatement(String stmt)
executeStatement
in interface RemoteStore
stmt
- the SQL statement text.int executeStatement(String stmt, Object... bindVars)
executeStatement
in interface RemoteStore
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the valueslong getOID()
getOID
in interface RemoteStore
Object getValue(String stmt)
getValue
in interface RemoteStore
stmt
- the SQL statement text.@Deprecated Object getValue(String stmt, int sqlType)
getValue
in interface RemoteStore
stmt
- the SQL statement text.sqlType
- if a special mapping of the database type to java type is needed, the type (java.sql.Types)
can be specified here.Object getValue(String stmt, Object... bindVars)
getValue
in interface RemoteStore
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the values@Deprecated Object getValue(String stmt, Object[] bindVars, int sqlType)
getValue
in interface RemoteStore
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the valuessqlType
- if a special mapping of the database type to java type is needed, the type (java.sql.Types)
can be specified here.Object getValue(int sqlType, String stmt, Object... bindVars)
getValue
in interface RemoteStore
sqlType
- if a special mapping of the database type to java type is needed, the type (java.sql.Types)
can be specified here.stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables, this should contain the values@Deprecated TableModel getTable(String q, Object... bindVars)
getTable
in interface RemoteStore
q
- the sql-querybindVars
- if the query contains place holders for binding variables this parameter should contain the valuesTableModel getTable(String q, Object[] bindVars, int[] sqlTypes)
getTable
in interface RemoteStore
q
- the sql-querybindVars
- if the query contains place holders for binding variables this parameter should contain the valuessqlTypes
- if a special mapping of database types to java types is needed, the types (java.sql.Types)
can be specified here. The length of the array must be equal to the number of columns in the result set.void setSchema(String schema)
setSchema
in interface RemoteStore
String getSchema()
getSchema
in interface RemoteStore
<P> P getNoCache(Class<? extends P> c, long oid)
Should only be needed in special circumstances like comparing the current state of an object to an old state in the database.
The result should be used with care, in particular, its unwise to change it in any way.
getNoCache
in interface RemoteStore
c
- the class of the objectoid
- the oid of the object@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.