Interface Store
- All Superinterfaces:
Remote
,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.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method throws anApplicationException
if a duplicate of the given object is in the database.void
checkUnique
(Persistent o, boolean caseInsensitive) This method throws anApplicationException
if a duplicate of the given object is in the database.int
This method returns the number of members of a given class matching the given condition.int
This method returns the number of members of a given class matching the given condition.int
delete
(Persistent o) Deletes the object from the database.int
Deletes some objects from the database.int
Deletes some objects from the database.int
delete
(Collection<?> collection) Deletes the objects of the collection from the database.int
executeStatement
(String stmt) Execute a SQL statement.int
executeStatement
(String stmt, Object... bindVars) Execute a SQL statement.<P extends Persistent>
List<P>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>
Set<P>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>
Set<P>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>
voidfillByFields
(Collection<P> collection, String fieldNames) Fetches dependent objects of a collection of Persistents reachable via the specified fields.<P> P
Method for getting objects from the database.<P> P
Method for getting objects from the database.<P> P
Method for getting objects from the database.<P extends Persistent>
PMethod for getting objects from the database.<P extends Persistent>
PMethod for getting objects from the database.<P extends Persistent>
PMethod for getting objects from the database.static Store
Get the Store to read and write from/to 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 databaseDeprecated, for removal: This API element is subject to removal in a future version.Returns the results of the given query.Execute a SQL statement which returns one value.Execute a SQL statement which returns one value.Deprecated, for removal: This API element is subject to removal in a future version.Execute a SQL statement which returns one value.Deprecated, for removal: This API element is subject to removal in a future version.boolean
Check whether the statement returns results.boolean
Check whether the object is in databasevoid
insert
(Persistent o) Insert the object into the database.void
insert
(Collection<?> collection) Insert the objects of the collection 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>
This method returns all members of the given class.<P> List<P>
This method returns the members of the given class matching the given condition.<P> List<P>
This method returns the members of the given class matching the given condition.<P> List<P>
This method returns the members of the given class matching the given condition.<P> List<P>
Deprecated, for removal: This API element is subject to removal in a future version.<P> List<P>
Deprecated, for removal: This API element is subject to removal in a future version.<P extends Persistent>
List<P>This method returns all members of the given class.<P extends Persistent>
List<P>This method returns the members of the given class matching the given condition.<P extends Persistent>
List<P>This method returns the members of the given class matching the given condition.<P extends Persistent>
List<P>This method returns the members of the given class matching the given condition.<P> List<P>
This method returns the members of the given class matching the given condition.<P extends Persistent>
List<P>This method returns the members of the given class matching the given condition.<P> Set<P>
This method returns the members of the given class matching the given condition as aSet
.<P extends Persistent>
Set<P>This method returns the members of the given class matching the given condition as aSet
.This method returns the members of the given class matching the given condition as aMap
.<P extends Persistent>
Map<Long,P> This method returns the members of the given class matching the given condition as aMap
.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.int
update
(Collection<?> collection) Updates the objects of the collection in the database.
-
Method Details
-
getInstance
Get the Store to read and write from/to the database.- Returns:
- a Store object
-
list
This method returns all members of the given class.- Specified by:
list
in interfaceRemoteStore
- Parameters:
c
- the class of the objects- Returns:
- a list of members of the given class
-
list
This method returns all members of the given class.- Specified by:
list
in interfaceRemoteStore
- Parameters:
classname
- the name of the class of the object- Returns:
- a List of members of the given class
-
list
This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
c
- the class of the objectscond
- a SQL condition- Returns:
- a List of members of the given class
-
list
This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
classname
- the name of the class of the objectcond
- a SQL condition- Returns:
- a List of members of the given class
-
list
This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
c
- the class of the objectscond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.- Returns:
- a List of members of the given class
-
list
This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
classname
- the name of the class of the objectcond
- a SQL conditionorder
- a comma separated list of attribute names of the given class.- Returns:
- a List of members of the given class
-
list
This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
limitedList
<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.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.
- Specified by:
limitedList
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
list
@Deprecated(since="10.0", forRemoval=true) <P> List<P> list(Class<? extends P> c, String cond, String order, Object[] bindVars, int maxRows) Deprecated, for removal: This API element is subject to removal in a future version.This method returns the members of the given class matching the given condition and limiting the returned entry count.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.
- Specified by:
list
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
limitedList
<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.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.
- Specified by:
limitedList
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
list
@Deprecated(since="10.0", forRemoval=true) <P> List<P> list(Class<? extends P> c, String cond, String order, Object[] bindVars, int maxRows, int offset) Deprecated, for removal: This API element is subject to removal in a future version.This method returns the members of the given class matching the given condition and limiting the returned entry count.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.
- Specified by:
list
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
list
<P extends Persistent> List<P> list(String classname, String cond, String order, Object... bindVars) This method returns the members of the given class matching the given condition.- Specified by:
list
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
list2
This method returns the members of the given class matching the given condition. the sql-query is a complete sql statement which must retrieve exactly the database attributes of the given class, for example: select u.* from avw_user u, avw_userrole ur where ... It is required to use theStoreUtil.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..."- Specified by:
list2
in interfaceRemoteStore
- Parameters:
c
- the class of the objectsq
- a SQL querybindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- a List of members of the given class
-
list2
This method returns the members of the given class matching the given condition. the sql-query is a complete sql statement which must retrieve exactly the database attributes of the given class, for example: select u.* from avw_user u, avw_userrole ur where ... It is required to use theStoreUtil.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..."- Specified by:
list2
in interfaceRemoteStore
- Parameters:
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- Returns:
- a List of members of the given class
-
table
This method returns the members of the given class matching the given condition as aMap
. The keys of the map are the oids of the objects as Long objects, the values are the objects itself.- Specified by:
table
in interfaceRemoteStore
- Parameters:
c
- the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- a Map of members of the given class
-
table
This method returns the members of the given class matching the given condition as aMap
. The keys of the table are the oids of the objects as Long objects, the values are the objects itself.- Specified by:
table
in interfaceRemoteStore
- Parameters:
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- Returns:
- a Map of members of the given class
-
setOf
This method returns the members of the given class matching the given condition as aSet
. The the values are the objects itself.- Specified by:
setOf
in interfaceRemoteStore
- Parameters:
c
- the class of the objectscond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- a Set of members of the given class
-
setOf
This method returns the members of the given class matching the given condition as aSet
. The keys of the table are the oids of the objects as Long objects, the values are the objects itself.- Specified by:
setOf
in interfaceRemoteStore
- Parameters:
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- Returns:
- a Set of members of the given class
-
count
This method returns the number of members of a given class matching the given condition.- Specified by:
count
in interfaceRemoteStore
- Parameters:
c
- the classcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- the number of elements
-
count
This method returns the number of members of a given class matching the given condition.- Specified by:
count
in interfaceRemoteStore
- Parameters:
classname
- the name of the classcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- the number of elements
-
inDatabase
Check whether the object is in database- Specified by:
inDatabase
in interfaceRemoteStore
- Returns:
- true if the object is in the database
-
hasRows
Check whether the statement returns results.- Specified by:
hasRows
in interfaceRemoteStore
- Parameters:
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the values- Returns:
- true if the result set is not empty
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
c
- the class of the objectoid
- the oid of the object- Returns:
- the object with a given oid
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
classname
- the name of the class of the objectoid
- the oid of the object- Returns:
- the object with a given oid
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
c
- the class of the objectcond
- a SQL condition- Returns:
- the object with a given oid
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
classname
- the name of the class of the objectcond
- a SQL condition- Returns:
- an object matching the given condition
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
c
- the class of the objectcond
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- an object matching the given condition
-
get
Method for getting objects from the database.- Specified by:
get
in interfaceRemoteStore
- Parameters:
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- Returns:
- an object matching the given condition
-
fill
<P> P fill(P o) Fill objects where only the oid is set.- if o is null: return o
- if o is filled: do nothing; return o
- if o is not in the objectcache: fill it, put it into the OC
- if there is an object oc in the objectcache which is equal to o, but oc != o, throw an 1107 exception
- Specified by:
fill
in interfaceRemoteStore
- Parameters:
o
- the object- Returns:
- the same object with fields set from the database
-
fill
Fills the objects within list l.- Specified by:
fill
in interfaceRemoteStore
- Parameters:
l
- the list of objects to be filled- Returns:
- a list of objects which are filled or remain unfilled if they could not be filled. The objects are in the same order as in l.
-
checkUnique
Description copied from interface:RemoteStore
This method throws anApplicationException
if a duplicate of the given object is in the database. It uses the key fields returned by methodPersistent.getKeys()
of objecto
for the comparison.- Specified by:
checkUnique
in interfaceRemoteStore
- Parameters:
o
- the object
-
checkUnique
Description copied from interface:RemoteStore
This method throws anApplicationException
if a duplicate of the given object is in the database. It uses the key fields returned by methodPersistent.getKeys()
of objecto
for the comparison.- Specified by:
checkUnique
in interfaceRemoteStore
- Parameters:
o
- the objectcaseInsensitive
- if true make string comparisons case insensitive
-
fillByField
<P extends Persistent,R extends Persistent> Set<P> 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. BulkQueries are used for efficient access of the database.- Specified by:
fillByField
in interfaceRemoteStore
- Parameters:
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 aPersistent
.- Returns:
- the set of referenced objects (filled)
-
fillByField
<P extends Persistent,R extends Persistent> Set<P> 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. BulkQueries are used for efficient access of the database.- Specified by:
fillByField
in interfaceRemoteStore
- Parameters:
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 aPersistent
.condition
- an optional SQL condition.bindVars
- optional array of parameter bindings for the SQL statement.- Returns:
- the set of referenced objects (filled)
-
fillByFields
Fetches dependent objects of a collection of Persistents reachable via the specified fields. BulkQueries are used for efficient access of the database.- Specified by:
fillByFields
in interfaceRemoteStore
- Parameters:
collection
- the Collection of referencing objects, must all be filled.fieldNames
- a comma separated string of field names. Every field name must denote aPersistent
field.
-
insert
Insert the object into the database. Does not write a LogEntry.- Specified by:
insert
in interfaceRemoteStore
- Parameters:
o
- the object
-
insert
Insert the objects of the collection into the database. Does not write LogEntry objects.- Specified by:
insert
in interfaceRemoteStore
- Parameters:
collection
- the objects to insert (all of the objects must implement Persistent)
-
update
Update the database tuple corresponding to the given object. Does not write a LogEntry.- Specified by:
update
in interfaceRemoteStore
- Parameters:
o
- the object- Returns:
- the number of updated tuples (0 or 1)
-
update
Updates the objects of the collection in the database. Does not write LogEntry objects.- Specified by:
update
in interfaceRemoteStore
- Parameters:
collection
- the objects to update (all of the objects must implement Persistent)- Returns:
- the number of updated tuples
-
update
Update some fields of the database tuple corresponding to the given object. Does not write a LogEntry.- Specified by:
update
in interfaceRemoteStore
- Parameters:
o
- the objectfieldNames
- an array containing the names of the fields which should be updated- Returns:
- the number of updated tuples (0 or 1)
-
delete
Deletes the object from the database. Does not write a LogEntry.- Specified by:
delete
in interfaceRemoteStore
- Parameters:
o
- the object to delete- Returns:
- the number of deleted tuples (0 or 1)
-
delete
Deletes the objects of the collection from the database. Does not write LogEntry objects.- Specified by:
delete
in interfaceRemoteStore
- Parameters:
collection
- the objects to delete (all of the objects must implement Persistent)- Returns:
- the number of deleted tuples
-
delete
Deletes some objects from the database. Does not write a LogEntry. Note that neither thePersistent.beforeDelete()
norPersistentEventHandler.beforeDelete(Persistent)
methods are called for the individual deleted objects.- Specified by:
delete
in interfaceRemoteStore
- Parameters:
c
- the class of the objectscondition
- a SQL conditionbindVars
- if the condition contains place holders for binding variables this parameter should contain the values- Returns:
- the number of deleted tuples
-
delete
Deletes some objects from the database. Does not write a LogEntry. Note that neither thePersistent.beforeDelete()
norPersistentEventHandler.beforeDelete(Persistent)
methods are called for the individual deleted objects.- Specified by:
delete
in interfaceRemoteStore
- Parameters:
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 values- Returns:
- the number of deleted tuples
-
executeStatement
Execute a SQL statement.- Specified by:
executeStatement
in interfaceRemoteStore
- Parameters:
stmt
- the SQL statement text.- Returns:
- the number of rows changed
-
executeStatement
Execute a SQL statement.- Specified by:
executeStatement
in interfaceRemoteStore
- Parameters:
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the values- Returns:
- the number of rows changed
-
getOID
long getOID()Return the next object id from the oid-factory in the database- Specified by:
getOID
in interfaceRemoteStore
- Returns:
- an unique object id
-
getValue
Execute a SQL statement which returns one value. The statement is executed, the first row fetched and from the result set the first element is returned.- Specified by:
getValue
in interfaceRemoteStore
- Parameters:
stmt
- the SQL statement text.- Returns:
- the value as object.
-
getValue
Deprecated, for removal: This API element is subject to removal in a future version.Execute a SQL statement which returns one value. The statement is executed, the first row fetched and from the result set the first element is returned.- Specified by:
getValue
in interfaceRemoteStore
- Parameters:
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.- Returns:
- the value as object.
-
getValue
Execute a SQL statement which returns one value. The statement is executed, the first row fetched and from the result set the first element is returned.- Specified by:
getValue
in interfaceRemoteStore
- Parameters:
stmt
- the SQL statement text.bindVars
- if the stmt contains place holders for binding variables this parameter should contain the values- Returns:
- the value as object.
-
getValue
@Deprecated(since="10.0", forRemoval=true) Object getValue(String stmt, Object[] bindVars, int sqlType) Deprecated, for removal: This API element is subject to removal in a future version.Execute a SQL statement which returns one value. The statement is executed, the first row fetched and from the result set the first element is returned.- Specified by:
getValue
in interfaceRemoteStore
- Parameters:
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.- Returns:
- the value as object.
-
getValue
Execute a SQL statement which returns one value. The statement is executed, the first row fetched and from the result set the first element is returned.- Specified by:
getValue
in interfaceRemoteStore
- Parameters:
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- Returns:
- the value as object.
-
getTable
Deprecated, for removal: This API element is subject to removal in a future version.Returns the results of the given query.- Specified by:
getTable
in interfaceRemoteStore
- Parameters:
q
- the sql-querybindVars
- if the query contains place holders for binding variables this parameter should contain the values- Returns:
- a list of list of values
-
getTable
Returns the results of the given query.- Specified by:
getTable
in interfaceRemoteStore
- Parameters:
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.- Returns:
- a list of list of values
-
getNoCache
Method for getting objects directly from the database bypassing the object cache.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.
- Specified by:
getNoCache
in interfaceRemoteStore
- Parameters:
c
- the class of the objectoid
- the oid of the object- Returns:
- the object with a given oid
-
limitedList(Class, int, String, String, Object...)
instead