com.groiss.store
Interface Store

All Superinterfaces:
java.rmi.Remote, RemoteStore

public interface Store
extends RemoteStore

The store interface represents the interface to the database. It is used for inserting, updating, deleting and retrieving objects. You get an object implementing this interface by calling com.groiss.wf.ServiceLocator.getStore() or - in case of RMI - using the getStore() call of com.groiss.wf.Session.

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
 int count(java.lang.Class<?> c, java.lang.String cond, java.lang.Object[] bindVars)
          This method returns the number of members of a given class matching the given condition.
 int count(java.lang.String classname, java.lang.String cond, java.lang.Object[] bindVars)
          This method returns the number of members of a given class matching the given condition.
 int delete(java.lang.Class<?> c, java.lang.String condition, java.lang.Object[] bindVars)
          Deletes some objects from the database.
 int delete(Persistent o)
          Deletes the object from the database.
 int delete(java.lang.String classname, java.lang.String condition, java.lang.Object[] bindVars)
          Deletes some objects from the database.
 int executeStatement(java.lang.String stmt)
          Execute a SQL statement.
 int executeStatement(java.lang.String stmt, java.lang.Object[] bindVars)
          Execute a SQL statement.
<P> P
fill(P o)
          Fill objects where only the oid is set.
<P extends Persistent,R extends Persistent>
java.util.Set<P>
fillByField(java.lang.Class<? extends P> c, java.util.Collection<R> collection, java.lang.String fieldname)
          Fill a heterogeneous set of Persistents referenced via a field of a collection of (persistent) objects.
<P extends Persistent,R extends Persistent>
java.util.Set<P>
fillByField(java.lang.Class<? extends P> c, java.util.Collection<R> collection, java.lang.String fieldname, java.lang.String condition, java.lang.Object[] bindVars)
          Fill a heterogeneous set of Persistents referenced via a field of a collection of (persistent) objects.
<P> P
get(java.lang.Class<? extends P> c, long oid)
          Method for getting objects from the database.
<P> P
get(java.lang.Class<? extends P> c, java.lang.String cond)
          Method for getting objects from the database.
<P> P
get(java.lang.Class<? extends P> c, java.lang.String cond, java.lang.Object[] bindVars)
          Method for getting objects from the database.
<P extends Persistent>
P
get(java.lang.String classname, long oid)
          Method for getting objects from the database.
<P extends Persistent>
P
get(java.lang.String classname, java.lang.String cond)
          Method for getting objects from the database.
<P extends Persistent>
P
get(java.lang.String classname, java.lang.String cond, java.lang.Object[] bindVars)
          Method for getting objects from the database.
<P> P
getNoCache(java.lang.Class<? extends P> c, long oid)
          Method for getting objects directly from the database bypassing the cache.
 long getOID()
          Return the next object id from the oid-factory in the database
 java.lang.String getSchema()
          Returns the schema of the tables
 javax.swing.table.TableModel getTable(java.lang.String q, java.lang.Object[] bindVars)
          Returns the results of the given query.
 javax.swing.table.TableModel getTable(java.lang.String q, java.lang.Object[] bindVars, int[] sqlTypes)
          Returns the results of the given query.
 java.lang.Object getValue(java.lang.String stmt)
          Execute a SQL statement which returns one value.
 java.lang.Object getValue(java.lang.String stmt, int sqlType)
          Execute a SQL statement which returns one value.
 java.lang.Object getValue(java.lang.String stmt, java.lang.Object[] bindVars)
          Execute a SQL statement which returns one value.
 java.lang.Object getValue(java.lang.String stmt, java.lang.Object[] bindVars, int sqlType)
          Execute a SQL statement which returns one value.
 boolean hasRows(java.lang.String stmt, java.lang.Object[] bindVars)
          Check whether the statement returns results.
 boolean inDatabase(Persistent o)
          Check whether the object is in database
 void insert(Persistent o)
          Insert the object into the database.
<P> java.util.List<P>
list(java.lang.Class<? extends P> c)
          This method returns all members of the given class.
<P> java.util.List<P>
list(java.lang.Class<? extends P> c, java.lang.String cond)
          This method returns the members of the given class matching the given condition.
<P> java.util.List<P>
list(java.lang.Class<? extends P> c, java.lang.String cond, java.lang.String order)
          This method returns the members of the given class matching the given condition.
<P> java.util.List<P>
list(java.lang.Class<? extends P> c, java.lang.String cond, java.lang.String order, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
<P> java.util.List<P>
list(java.lang.Class<? extends P> c, java.lang.String cond, java.lang.String order, java.lang.Object[] bindVars, int maxRows)
          This method returns the members of the given class matching the given condition and limiting the returned entry count.
<P extends Persistent>
java.util.List<P>
list(java.lang.String classname)
          This method returns all members of the given class.
<P extends Persistent>
java.util.List<P>
list(java.lang.String classname, java.lang.String cond)
          This method returns the members of the given class matching the given condition.
<P extends Persistent>
java.util.List<P>
list(java.lang.String classname, java.lang.String cond, java.lang.String order)
          This method returns the members of the given class matching the given condition.
<P extends Persistent>
java.util.List<P>
list(java.lang.String classname, java.lang.String cond, java.lang.String order, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
<P> java.util.List<P>
list2(java.lang.Class<? extends P> c, java.lang.String q, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
<P extends Persistent>
java.util.List<P>
list2(java.lang.String classname, java.lang.String q, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
 void setSchema(java.lang.String schema)
          Set the schema of the tables
<P> java.util.Map<java.lang.Long,P>
table(java.lang.Class<? extends P> c, java.lang.String cond, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
<P extends Persistent>
java.util.Map<java.lang.Long,P>
table(java.lang.String classname, java.lang.String cond, java.lang.Object[] bindVars)
          This method returns the members of the given class matching the given condition.
 int update(Persistent o)
          Update the database tuple corresponding to the given object.
 int update(Persistent o, java.lang.String... fieldNames)
          Update some fields of the database tuple corresponding to the given object.
 

Method Detail

list

<P> java.util.List<P> list(java.lang.Class<? extends P> c)
This method returns all members of the given class.

Specified by:
list in interface RemoteStore
Parameters:
c - the class of the objects
Returns:
a list of members of the given class

list

<P extends Persistent> java.util.List<P> list(java.lang.String classname)
This method returns all members of the given class.

Specified by:
list in interface RemoteStore
Parameters:
classname - the name of the class of the object
Returns:
a List of members of the given class

list

<P> java.util.List<P> list(java.lang.Class<? extends P> c,
                           java.lang.String cond)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
c - the class of the objects
cond - a SQL condition
Returns:
a List of members of the given class

list

<P extends Persistent> java.util.List<P> list(java.lang.String classname,
                                              java.lang.String cond)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
classname - the name of the class of the object
cond - a SQL condition
Returns:
a List of members of the given class

list

<P> java.util.List<P> list(java.lang.Class<? extends P> c,
                           java.lang.String cond,
                           java.lang.String order)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
c - the class of the objects
cond - a SQL condition
order - a comma separated list of attribute names of the given class.
Returns:
a List of members of the given class

list

<P extends Persistent> java.util.List<P> list(java.lang.String classname,
                                              java.lang.String cond,
                                              java.lang.String order)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
classname - the name of the class of the object
cond - a SQL condition
order - a comma separated list of attribute names of the given class.
Returns:
a List of members of the given class

list

<P> java.util.List<P> list(java.lang.Class<? extends P> c,
                           java.lang.String cond,
                           java.lang.String order,
                           java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
c - the class of the objects
cond - a SQL condition
order - a comma separated list of attribute names of the given class.
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a List of members of the given class

list

<P> java.util.List<P> list(java.lang.Class<? extends P> c,
                           java.lang.String cond,
                           java.lang.String order,
                           java.lang.Object[] bindVars,
                           int maxRows)
This method returns the members of the given class matching the given condition and limiting the returned entry count.

Specified by:
list in interface RemoteStore
Parameters:
c - the class of the objects
cond - a SQL condition
order - a comma separated list of attribute names of the given class.
bindVars - if the condition contains place holders for binding variables this array should contain the values
maxRows - the maximum number of entries to return
Returns:
a List of members of the given class

list

<P extends Persistent> java.util.List<P> list(java.lang.String classname,
                                              java.lang.String cond,
                                              java.lang.String order,
                                              java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition.

Specified by:
list in interface RemoteStore
Parameters:
classname - the name of the class of the objects
cond - a SQL condition
order - a comma separated list of attribute names of the given class.
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a List of members of the given class

list2

<P> java.util.List<P> list2(java.lang.Class<? extends P> c,
                            java.lang.String q,
                            java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition. the sql-query is a complete sql statement which must retreive 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 the StoreUtil.dbAttrs(Persistent, String) dbAttrs(String) method to construct the attribute list, that is to formulate "select "+StoreUtil.dbAttrs(user,"u")+" from avwuser u, avw_userrole ur where..."

Specified by:
list2 in interface RemoteStore
Parameters:
c - the class of the objects
q - a SQL query
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a List of members of the given class

list2

<P extends Persistent> java.util.List<P> list2(java.lang.String classname,
                                               java.lang.String q,
                                               java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition. the sql-query is a complete sql statement which must retreive 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 the StoreUtil.dbAttrs(Persistent, String) dbAttrs(String) method to construct the attribute list, that is to formulate "select "+StoreUtil.dbAttrs(user,"u")+" from avwuser u, avw_userrole ur where..."

Specified by:
list2 in interface RemoteStore
Parameters:
classname - the name of the class of the objects
q - a SQL query
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a List of members of the given class

table

<P> java.util.Map<java.lang.Long,P> table(java.lang.Class<? extends P> c,
                                          java.lang.String cond,
                                          java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition. The keys of the table are the oids of the objects as Long objects, the values are the objects itself.

Specified by:
table in interface RemoteStore
Parameters:
c - the class of the objects
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a Map of members of the given class

table

<P extends Persistent> java.util.Map<java.lang.Long,P> table(java.lang.String classname,
                                                             java.lang.String cond,
                                                             java.lang.Object[] bindVars)
This method returns the members of the given class matching the given condition. The keys of the table are the oids of the objects as Long objects, the values are the objects itself.

Specified by:
table in interface RemoteStore
Parameters:
classname - the name of the class of the objects
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
a Map of members of the given class

count

int count(java.lang.Class<?> c,
          java.lang.String cond,
          java.lang.Object[] bindVars)
This method returns the number of members of a given class matching the given condition.

Specified by:
count in interface RemoteStore
Parameters:
c - the class
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
the number of elements

count

int count(java.lang.String classname,
          java.lang.String cond,
          java.lang.Object[] bindVars)
This method returns the number of members of a given class matching the given condition.

Specified by:
count in interface RemoteStore
Parameters:
classname - the name of the class
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
the number of elements

inDatabase

boolean inDatabase(Persistent o)
Check whether the object is in database

Specified by:
inDatabase in interface RemoteStore
Returns:
true if the object is in the database

hasRows

boolean hasRows(java.lang.String stmt,
                java.lang.Object[] bindVars)
Check whether the statement returns results.

Specified by:
hasRows in interface RemoteStore
Parameters:
stmt - the SQL statement text.
bindVars - if the stmt contains place holders for binding variables this array should contain the values
Returns:
true if the result set is not empty

get

<P> P get(java.lang.Class<? extends P> c,
          long oid)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
c - the class of the object
oid - the oid of the object
Returns:
the object with a given oid

get

<P extends Persistent> P get(java.lang.String classname,
                             long oid)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
classname - the name of the class of the object
oid - the oid of the object
Returns:
the object with a given oid

get

<P> P get(java.lang.Class<? extends P> c,
          java.lang.String cond)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
c - the class of the object
cond - a SQL condition
Returns:
the object with a given oid

get

<P extends Persistent> P get(java.lang.String classname,
                             java.lang.String cond)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
classname - the name of the class of the object
cond - a SQL condition
Returns:
an object matching the given condition

get

<P> P get(java.lang.Class<? extends P> c,
          java.lang.String cond,
          java.lang.Object[] bindVars)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
c - the class of the object
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
an object matching the given condition

get

<P extends Persistent> P get(java.lang.String classname,
                             java.lang.String cond,
                             java.lang.Object[] bindVars)
Method for getting objects from the database.

Specified by:
get in interface RemoteStore
Parameters:
classname - the name of the class of the object
cond - a SQL condition
bindVars - if the condition contains place holders for binding variables this array 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.

Specified by:
fill in interface RemoteStore
Parameters:
o - the object
Returns:
the same object with fields set from the database

fillByField

<P extends Persistent,R extends Persistent> java.util.Set<P> fillByField(java.lang.Class<? extends P> c,
                                                                         java.util.Collection<R> collection,
                                                                         java.lang.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 interface RemoteStore
Parameters:
c - (super)class of the referenced Objects
collection - the Collection of referencing objects, must all be filled.
Returns:
the set of referenced objects (filled)

fillByField

<P extends Persistent,R extends Persistent> java.util.Set<P> fillByField(java.lang.Class<? extends P> c,
                                                                         java.util.Collection<R> collection,
                                                                         java.lang.String fieldname,
                                                                         java.lang.String condition,
                                                                         java.lang.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 interface RemoteStore
Parameters:
c - (super)class of the referenced Objects
collection - the Collection of referencing objects, must all be filled.
condition - an optional SQL condition.
bindVars - optional array of parameter bindings for the SQL statement.
Returns:
the set of referenced objects (filled)

insert

void insert(Persistent o)
Insert the object into the database.

Specified by:
insert in interface RemoteStore
Parameters:
o - the object

update

int update(Persistent o)
Update the database tuple corresponding to the given object.

Specified by:
update in interface RemoteStore
Parameters:
o - the object

update

int update(Persistent o,
           java.lang.String... fieldNames)
Update some fields of the database tuple corresponding to the given object.

Specified by:
update in interface RemoteStore
Parameters:
o - the object
fieldNames - an array containing the names of the fields which should be updated

delete

int delete(Persistent o)
Deletes the object from the database.

Specified by:
delete in interface RemoteStore
Parameters:
o - the object to delete
Returns:
the number of deleted tuples (0 or 1)

delete

int delete(java.lang.Class<?> c,
           java.lang.String condition,
           java.lang.Object[] bindVars)
Deletes some objects from the database. Note that neither the Persistent.onDelete() nor PersistentEventHandler.onDelete(Persistent) methods are called for the individual deleted objects.

Specified by:
delete in interface RemoteStore
Parameters:
c - the class of the objects
condition - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
the number of deleted tuples

delete

int delete(java.lang.String classname,
           java.lang.String condition,
           java.lang.Object[] bindVars)
Deletes some objects from the database. Note that neither the Persistent.onDelete() nor PersistentEventHandler.onDelete(Persistent) methods are called for the individual deleted objects.

Specified by:
delete in interface RemoteStore
Parameters:
classname - the name of the class of the objects
condition - a SQL condition
bindVars - if the condition contains place holders for binding variables this array should contain the values
Returns:
the number of deleted tuples

executeStatement

int executeStatement(java.lang.String stmt)
Execute a SQL statement.

Specified by:
executeStatement in interface RemoteStore
Parameters:
stmt - the SQL statement text.
Returns:
the number of rows changed

executeStatement

int executeStatement(java.lang.String stmt,
                     java.lang.Object[] bindVars)
Execute a SQL statement.

Specified by:
executeStatement in interface RemoteStore
Parameters:
stmt - the SQL statement text.
bindVars - if the stmt contains place holders for binding variables this array 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 interface RemoteStore
Returns:
an unique object id

getValue

java.lang.Object getValue(java.lang.String stmt)
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 interface RemoteStore
Parameters:
stmt - the SQL statement text.
Returns:
the value as object.

getValue

java.lang.Object getValue(java.lang.String stmt,
                          int sqlType)
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 interface RemoteStore
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

java.lang.Object getValue(java.lang.String stmt,
                          java.lang.Object[] bindVars)
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 interface RemoteStore
Parameters:
stmt - the SQL statement text.
bindVars - if the stmt contains place holders for binding variables this array should contain the values
Returns:
the value as object.

getValue

java.lang.Object getValue(java.lang.String stmt,
                          java.lang.Object[] bindVars,
                          int sqlType)
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 interface RemoteStore
Parameters:
stmt - the SQL statement text.
bindVars - if the stmt contains place holders for binding variables this array should contain the values
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.

getTable

javax.swing.table.TableModel getTable(java.lang.String q,
                                      java.lang.Object[] bindVars)
Returns the results of the given query.

Specified by:
getTable in interface RemoteStore
Parameters:
q - the sql-query
bindVars - if the query contains place holders for binding variables this array should contain the values
Returns:
a list of list of values

getTable

javax.swing.table.TableModel getTable(java.lang.String q,
                                      java.lang.Object[] bindVars,
                                      int[] sqlTypes)
Returns the results of the given query.

Specified by:
getTable in interface RemoteStore
Parameters:
q - the sql-query
bindVars - if the query contains place holders for binding variables this array should contain the values
sqlTypes - 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

setSchema

void setSchema(java.lang.String schema)
Set the schema of the tables

Specified by:
setSchema in interface RemoteStore

getSchema

java.lang.String getSchema()
Returns the schema of the tables

Specified by:
getSchema in interface RemoteStore

getNoCache

<P> P getNoCache(java.lang.Class<? extends P> c,
                 long oid)
Method for getting objects directly from the database bypassing the cache.

Specified by:
getNoCache in interface RemoteStore
Parameters:
c - the class of the object
oid - the oid of the object
Returns:
the object with a given oid


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.