Package overit.geocall.da
Class DABase
java.lang.Object
overit.geocall.da.DABase
- All Implemented Interfaces:
Serializable,DataAttributesHolder,EDMConfigurableBean,overit.geocall.marks.FieldExposer,overit.geocall.marks.NameExposer,DBFieldMapper,DBObjectMapper,Identified,Tool
- Direct Known Subclasses:
overit.geocallapp.replicator.basic.base.DataSource.DABaseReplicator,DADashboard,DAMessages,DAOUserPassword,DAUsers,DAXWFMAAvvisi,DAXWFMAAvvisiAttivita,DAXWFMAAvvisiCataloghi,DAXWFMAAvvisiRighe,DAXWFMAAvvisiTesto,DAXWFMAProgressiviAvvisi,DAXWFMRNotifTypeOrderType,DAXWFMTAutomiRighe,DAXWFMTGruppoCatalogo,DAXWFMTParametriAutomiAvvisi,DAXWFMTStatoAvvisoSAP,DAXWFMTTipoCatalogo
public abstract class DABase
extends Object
implements DBFieldMapper, DBObjectMapper, Identified, overit.geocall.marks.FieldExposer, overit.geocall.marks.NameExposer, Serializable, Tool, EDMConfigurableBean
Abstract class to extend when you want to create an object that accesses a table of the database.
To use the class you need to extend it by implementing the methods that gives the fundamental informations of the table that you want to map.
This class implements some basic functions such the selection of one or all the table records (see
You can add specific custom queries and commands by implementing the methods
It is possible to save a
It is also possible to define one
All methods requires that a query id or command id is passed as well as one connection already open (or the name of a pool from which to extract a new one). If we pass a pool name, the methods extract a connection and in the end of the execution try to release it giving a commit command; if an error occurs it comes is performed a rollback and then the connection is released to the pool.
If the connection is not explicitly passed, the commit method is never made and the transactions must be managed from the caller.
In any case, any exception generated is thrown outside.
This class implements some basic functions such the selection of one or all the table records (see
executeQuery())
or the deletion, insertion or updating of a record
(see executeCommand()). You can add specific custom queries and commands by implementing the methods
giveQueries() and
giveCommands(). It is possible to save a
DBView on which insertions, deletions and modifications have been made using the
save() method. It is also possible to define one
DBObjectMap or a DBFieldMap to change the behavior of standard queries implementing the two methods
giveDBObjectMap() and giveDBFieldMap(). All methods requires that a query id or command id is passed as well as one connection already open (or the name of a pool from which to extract a new one). If we pass a pool name, the methods extract a connection and in the end of the execution try to release it giving a commit command; if an error occurs it comes is performed a rollback and then the connection is released to the pool.
If the connection is not explicitly passed, the commit method is never made and the transactions must be managed from the caller.
In any case, any exception generated is thrown outside.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intStandard command: delete a record using the filter passed as parameterstatic final intStandard command: delete a record using the primary key fieldstatic final intStandard experimental command: INSATE implementation (try to make an insert, if fails do an update)static final intStandard command: insert a new recordstatic final intstatic final intstatic final intStandard query: SELECT * FROM TABLE WHERE ... = ?static final intStandard empty query: SELECT * FROM TABLE WHERE 1 = 0static final intStandard query: SELECT * FROM TABLE WHERE PRIMARY_KEY = ?static final intStandard command: update a record using the filter passed as parameterstatic final intStandard command: update a record using the primary keystatic final intStandard experimental command: UPSERT implementation (try to make an update, if fails do an insert) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcommand(int commandId, HashGetter filter, HashGetter values) Executes a command.intcommand(int iCommandId, HashGetter filter, HashGetter values, PooledConnection conn) Executes a command.intcommand(int commandId, HashGetter filter, HashGetter values, PooledConnection conn, DBStatementObserver observer) Executes a command.protected LonggetAutoIncrementVal(DBStatement insertDbs, PooledConnection conn) Retrieves the new id according to the specific DB.Returns theDBFieldMapused by the statements to do the data readings and writingsMakes a fetch on the table associated to the specific DA, to retrieve theDBFields, an ordered Field collection access by nameReturns theDBObjectMapof the instanceDeprecated.Retrieves anIdentityobject used to store the informations about the user currently logged in the application.static intgetQueryId(String id, int def, DABase da) Returns the id of the query passed as parameterstatic intgetQueryId(String id, DABase da) Returns the id of the query passed as parameterString[]getReadOnlyCols(DBView dbv) Given a DBView return an array of strings that contains the names of the read-only columns of the DBViewprotected LongRetrieves the new sequence value according to the specific DB.Returns theTeacherused for the translations by the DAabstract StringReturns the field of the table in which is stored the "branch id" valueprotected abstract intgiveCommands(int i, PooledConnection conn, DBStatement stmt, HashGetter filter, HashGetter values) Implements new specific commands that are different from the standard ones.abstract DBFieldMapMust returns aDBFieldMapif you want to implement an object mapping mechanism for queries and standard commands.abstract DBObjectMapMust returns aDBObjectMapif you want to implement an object mapping mechanism for queries and standard commands.abstract StringReturns the field of the table in which is stored the "factory id" valuebooleanReturnstrueif thisDABaseshould produce aSELECT DISTINCT query;falseif it should produce aSELECT (not DISTINCT) query.booleanAllows customization of service mode for the Connection extraction.protected intDefines the minumum level of behavior.abstract String[]Returns the array that contains the names of the columns on which we made the sorting of the result.abstract StringReturns the name of the pool from which the specific DA extracts the connections when they are not explicitly passed to methods.abstract String[]Must be implemented and returns the array that contains the primary keys of the specific table on which the DA acts.protected abstract DBViewgiveQueries(int i, PooledConnection conn, DBStatement stmt, HashGetter filter, int maxrows, int skiprows) Implements new specific queries that are different from the standard ones.abstract StringMust be implemented and returns a string that represent the name of the field used as sequence for the insert commands on the table.giveStar()Defines the field list for all the select queries.abstract StringReturns the name of the table on which the specific DA acts.booleanReturnstruein case thisEDMConfigurableBeanhas not been already decorated withEDMconfiguration;falseotherwise.booleanDetects whether a DBFieldMap object exists or not.booleanDetects whether a DBObjectMap object exists or notvoidMark thisEDMConfigurableBeanas already decorated withEDMconfiguration.protected voidpostDelete(HashGetter filter, PooledConnection conn) Called after every delete command.protected voidpostInsert(HashGetter values, PooledConnection conn, DBStatement insertDbs) Called after every insert command.protected voidpostUpdate(HashGetter filter, HashGetter values, PooledConnection conn) Called after every update command.protected voidpreDelete(HashGetter filter, PooledConnection conn) Called before every delete command.protected voidpreInsert(HashGetter values, PooledConnection conn) Called before every insert command.protected voidpreQuery(HashGetter filter, PooledConnection conn) Called before every query.protected voidpreUpdate(HashGetter filter, HashGetter values, PooledConnection conn) Called before every update command.query(int queryid, HashGetter values, int maxrows) Executes a query.query(int queryid, HashGetter values, int maxrows, int skiprows) Executes a query.query(int queryid, HashGetter values, int maxrows, int skiprows, PooledConnection conn) Executes a query.query(int queryid, HashGetter values, int maxrows, int skiprows, PooledConnection conn, DBStatementObserver observer) Executes a query.query(int queryid, HashGetter values, int maxrows, PooledConnection conn) Executes a query.voidrelease(PooledConnection conn) Releases a connection and returns it to the pool from which it has been extractedremoveReadOnlyCols(DBView dbv) Resets the definition of the read-only columns for the DBViewbooleanSaves the information contained in a DBView by performing an insert of all the DBView records after deleting those previously present in DB.booleanreplace(DBView dbv, PooledConnection conn, String[] keys) Saves the information contained in a DBView by performing an insert of all the DBView records after deleting those previously present in DB.booleanTakes aDBViewas parameter and performs on the database all the operation (insert, delete, update) that have been done on the DBView itself.booleansave(DBView dbv, PooledConnection conn) Takes aDBViewas parameter and performs on the database all the operation (insert, delete, update) that have been done on the DBView itself.voidsetDataAttributes(List<DataAttribute> dataAttributes) Sets the provideddataAttributes.voidsetDBFieldMap(DBFieldMap fieldmap) Deprecated.Don't use this method, usegiveDBObjectMap()instead.voidsetDBObjectMap(DBObjectMap objectmap) Deprecated.Don't use this method, usegiveDBObjectMap()instead.voidsetIdentity(Identity identity) Sets aIdentityobject used to store the informations about the user currently logged in the application.setReadOnlyCols(DBView dbv, String[] columns) Allows you to specify which ones are the read-only columns of aDBViewand should be used when you want to save a DBView that has been created using a custom query that use a join on multiple tables.useConnection(String poolName, int cmdId) Extracts a connection from the poolMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface overit.geocall.edm.model.DataAttributesHolder
getEntitiesMethods inherited from interface overit.geocall.edm.model.EDMConfigurableBean
getEntity, hasEntity
-
Field Details
-
SELECT_FILTER
public static final int SELECT_FILTERStandard query: SELECT * FROM TABLE WHERE ... = ?- See Also:
-
SELECT_NONE
public static final int SELECT_NONEStandard empty query: SELECT * FROM TABLE WHERE 1 = 0- See Also:
-
SELECT_PK
public static final int SELECT_PKStandard query: SELECT * FROM TABLE WHERE PRIMARY_KEY = ?- See Also:
-
DELETE_PK
public static final int DELETE_PKStandard command: delete a record using the primary key field- See Also:
-
DELETE_FILTER
public static final int DELETE_FILTERStandard command: delete a record using the filter passed as parameter- See Also:
-
UPDATE_PK
public static final int UPDATE_PKStandard command: update a record using the primary key- See Also:
-
UPDATE_FILTER
public static final int UPDATE_FILTERStandard command: update a record using the filter passed as parameter- See Also:
-
INSERT
public static final int INSERTStandard command: insert a new record- See Also:
-
UPSERT
public static final int UPSERTStandard experimental command: UPSERT implementation (try to make an update, if fails do an insert)- See Also:
-
INSATE
public static final int INSATEStandard experimental command: INSATE implementation (try to make an insert, if fails do an update)- See Also:
-
SAVE_DBVIEW
public static final int SAVE_DBVIEW- See Also:
-
REPLACE_DBVIEW
public static final int REPLACE_DBVIEW- See Also:
-
DA_BASE_FILTER_PREFIX
- See Also:
-
-
Constructor Details
-
DABase
protected DABase()Creates a newDABaseinstance.
-
-
Method Details
-
getTeacher
Returns theTeacherused for the translations by the DA- Returns:
- The
Teacherinstance associated to the DA
-
giveMinLevel
protected int giveMinLevel()Defines the minumum level of behavior.
With value 0 (used in kernel versions <= 6.1) the delete commands receive the values (unnecessarily) while the custom commands did not (wrongly) receive the filters; with value 1 (used in kernel versions > 6.1) the behavior is regularized, ie delete commands do not receive values, insert commands do not receive filters and all others receive both.- Returns:
- The minimum level, 0
-
giveTableName
Returns the name of the table on which the specific DA acts. It must be implemented making it return a string that represents the name of the table on which you want to access and operate.- Returns:
- The name of the table on which the specific DA acts
-
givePoolName
Returns the name of the pool from which the specific DA extracts the connections when they are not explicitly passed to methods. It must be implemented making it return a string that represents the name of the pool.- Returns:
- The name of the pool from which the specific DA extracts the connections. It must return a not-null value
-
giveIsService
public boolean giveIsService()Allows customization of service mode for the Connection extraction.- Returns:
- false for ordinary Connection extraction, true for ServicePool extraction
-
giveStar
Defines the field list for all the select queries.- Returns:
- By default returns the star character (*), that means that we load all the table fields. It can be extended and make it return
a subset or a superset (calculated fields) using
fetch(givePool(),giveTableName()).
-
givePrimaryKeys
Must be implemented and returns the array that contains the primary keys of the specific table on which the DA acts.- Returns:
- Array that contains the name of the fields that are primary keys of the specific table
-
giveSequenceField
Must be implemented and returns a string that represent the name of the field used as sequence for the insert commands on the table.- Returns:
- The name of the sequence field or null if there isn't a defined sequence
-
giveOrderCols
Returns the array that contains the names of the columns on which we made the sorting of the result.- Returns:
- Array that contains the name of the fields of the specific table
-
giveFactoryField
Returns the field of the table in which is stored the "factory id" value- Returns:
- The field containing the "factory id" value
-
giveBranchField
Returns the field of the table in which is stored the "branch id" value- Returns:
- The name of the table field in which we store the "branch id" value; it must retrun null if we don't want to store this information
-
giveQueries
protected abstract DBView giveQueries(int i, PooledConnection conn, DBStatement stmt, HashGetter filter, int maxrows, int skiprows) throws SQLException Implements new specific queries that are different from the standard ones.
For all the queries implemented with this method we must set, in theDBStatement, the SQL (setSql()), the parameters (available as filters and settable usingset()) and any map (setDBObjectMap(),setDBFieldMap()) to use on the DBStatement.
The execution is done when we call one of thequery()methods, so we can do here only the statement setup.
It is fundamental that the method return null if the query id is not recognized.- Parameters:
i- The id of the queryconn- Connection from which we have extracted the DBStatement; it can be used to extract other DBStatementstmt- DBStatement used to set the SQL code and the parametersfilter- Parameters to set in the DBStatementmaxrows- Maximum rows number extracted with the queryskiprows- Number of initial lines that you do not want to be returned. Even these lines, although skipped, are counted in the maxrows parameter.- Returns:
- If the query id is valid we must return the DBStatement passed as parameter; if the is is not valid, or we don't want to add specific queries to the standard ones we must return null
- Throws:
SQLException- If there is an error in the SQL SQLException is thrown
-
giveCommands
protected abstract int giveCommands(int i, PooledConnection conn, DBStatement stmt, HashGetter filter, HashGetter values) throws SQLException Implements new specific commands that are different from the standard ones.
For all the commands implemented with this method we must set, in theDBStatement, the SQL (setSql()), (setDBObjectMap(),setDBFieldMap()) to use on the DBStatement.
The execution is done when we call one of thecommand()methods, so we can do here only the statement setup.
It is fundamental that the method return null if the command id is not recognized.- Parameters:
i- The id of the commandconn- Connection from which we have extracted the DBStatement; it can be used to extract other DBStatementstmt- DBStatement used to set the SQL code and the parametersfilter- Values used as filters to set for the update commandsvalues- Values to set as parameters in the DBStatement- Returns:
- If the command id is valid we must return the DBStatement passed as parameter; if the id is not valid, or we don't want to add specific commands to the standard ones we must return null
- Throws:
SQLException- If there is an error in the SQL SQLException is thrown
-
giveDBObjectMap
Must returns aDBObjectMapif you want to implement an object mapping mechanism for queries and standard commands. If you do not want to define any mapping just make sure that the method returns null.- Returns:
- the DBObjectMapper that defines the object mapping, or null
-
giveDBFieldMap
Must returns aDBFieldMapif you want to implement an object mapping mechanism for queries and standard commands. If you do not want to define any mapping just make sure that the method returns null.- Returns:
- the DBFieldMapper that defines the object mapping, or null
-
giveIsDistinct
public boolean giveIsDistinct()Returnstrueif thisDABaseshould produce aSELECT DISTINCT query;falseif it should produce aSELECT (not DISTINCT) query.- Returns:
trueif thisDABaseshould produce aSELECT DISTINCT query;falseif it should produce aSELECT (not DISTINCT) query.
-
preInsert
protected void preInsert(HashGetter values, PooledConnection conn) throws DAValidateException, SQLException Called before every insert command. We can overload it to implements specific operations. The standard method set the LOGIN and DATASTAMP fields and eventually the values for the factory, branch and sequence fields.- Parameters:
values- Map that contains the fields that we want to insertconn- Connection with which we act- Throws:
DAValidateException- If there is a validation error the DAValidateException is thrownSQLException- If there is an error in the SQL SQLException is thrown
-
postInsert
protected void postInsert(HashGetter values, PooledConnection conn, DBStatement insertDbs) throws SQLException Called after every insert command. We can overload it to implements specific operations. The standard method eventually increment the sequence- Parameters:
values- Map that contains the fields that we have insertedconn- Connection with which we actinsertDbs- Statement on which we have done the insert- Throws:
SQLException- If there is an error in the SQL SQLException is thrown
-
preUpdate
protected void preUpdate(HashGetter filter, HashGetter values, PooledConnection conn) throws DAValidateException, SQLException Called before every update command. We can overload it to implements specific operations. The standard method set the LOGIN and DATASTAMP fields and eventually the values for the factory, branch and sequence fields.- Parameters:
filter- Map that contains the filter used to select the rows to updatevalues- Map with the values that will be used to the updateconn- Connection with which we act- Throws:
DAValidateException- If there is a validation error the DAValidateException is thrownSQLException- If there is an SQL error the SQLException is thrown
-
postUpdate
Called after every update command. We can overload it to implements specific operations The standard method do nothing.- Parameters:
filter- Map that contains the filter used to select the rows to updatevalues- Map with the values that are used to the updateconn- Connection with which we act
-
preDelete
protected void preDelete(HashGetter filter, PooledConnection conn) throws DAValidateException, SQLException Called before every delete command. We can overload it to implements specific operations. The standard method eventually set the values for the factory, branch and sequence fields.- Parameters:
filter- Map that contains the filter used to select the rows to deleteconn- Connection with which we act- Throws:
DAValidateException- If there is a validation error the DAValidateException is thrownSQLException- If there is an SQL error the SQLException is thrown
-
postDelete
Called after every delete command. We can overload it to implements specific operations The standard method do nothing- Parameters:
filter- Map that contains the filter used to select the rows to deleteconn- Connection with which we act
-
preQuery
protected void preQuery(HashGetter filter, PooledConnection conn) throws DAValidateException, SQLException Called before every query. We can overload it to implements specific operations The standard method eventually set the values for the factory and the branch fields.- Parameters:
filter- Map that contains the filter used as parameters for the queryconn- Connection with which we act- Throws:
DAValidateException- If there is a validation error the DAValidateException is thrownSQLException- If there is an error in the SQL SQLException is thrown
-
getIdentity
Retrieves anIdentityobject used to store the informations about the user currently logged in the application.- Specified by:
getIdentityin interfaceIdentified- Returns:
- The object that contains the informations about the user currently logged in the application
-
setIdentity
Sets aIdentityobject used to store the informations about the user currently logged in the application.- Specified by:
setIdentityin interfaceIdentified- Parameters:
identity- The object to set
-
haveDBFieldMap
public boolean haveDBFieldMap()Detects whether a DBFieldMap object exists or not.- Specified by:
haveDBFieldMapin interfaceDBFieldMapper- Returns:
- true if there is a specific DBFieldMap object, false otherwise
-
setDBObjectMap
Deprecated.Don't use this method, usegiveDBObjectMap()instead.Description copied from interface:DBObjectMapperSets theDBObjectMapcontained in the instance- Specified by:
setDBObjectMapin interfaceDBObjectMapper- Parameters:
objectmap- The map of objects used in this instance
-
haveDBObjectMap
public boolean haveDBObjectMap()Detects whether a DBObjectMap object exists or not- Specified by:
haveDBObjectMapin interfaceDBObjectMapper- Returns:
- true if there is a specific DBFieldMap object different from
null, false otherwise
-
setDBFieldMap
Deprecated.Don't use this method, usegiveDBObjectMap()instead.Description copied from interface:DBFieldMapperSets theDBFieldMapobject- Specified by:
setDBFieldMapin interfaceDBFieldMapper- Parameters:
fieldmap- The map used for the transformations of fields names
-
getDBObjectMap
Returns theDBObjectMapof the instance- Specified by:
getDBObjectMapin interfaceDBObjectMapper- Returns:
- The map used in the instance
-
getDBFieldMap
Returns theDBFieldMapused by the statements to do the data readings and writings- Specified by:
getDBFieldMapin interfaceDBFieldMapper- Returns:
- The map used by the statemets
-
setReadOnlyCols
Allows you to specify which ones are the read-only columns of aDBViewand should be used when you want to save a DBView that has been created using a custom query that use a join on multiple tables. The read-only columns are not saved by thesave()method.- Parameters:
dbv- the DBView for which you want to set the read-only columnscolumns- Arrays of strings with colums names- Returns:
- The DBView which the desired columns are set as read-only
-
getReadOnlyCols
Given a DBView return an array of strings that contains the names of the read-only columns of the DBView- Parameters:
dbv- The DBView for which you want to know the read-only columns- Returns:
- Array containing the names of the read-only columns. If there aren't read-only columns il will return null
-
removeReadOnlyCols
Resets the definition of the read-only columns for the DBView- Parameters:
dbv- The DBView for which you want to reset the definition of the read-only columns- Returns:
- DBView where all the columns are no longer read-only
-
query
Executes a query. The query is specified by a unique numeric id; it can be one of the predefined ids (like SELECT_FILTER, SELECT_NONE or SELECT_PK) or one specific defined by thegiveQueries()method- Parameters:
queryid- Numeric id that identifies the specific queryvalues- Map that contains the values that will be associated to the parameters of the query (it can be null)maxrows- Maximum numer of rows to extract (0 if we want to extract ALL the rows)- Returns:
- A DBView that contains the data extracted by the query
-
query
Executes a query. The query is specified by a unique numeric id; it can be one of the predefined ids (like SELECT_FILTER, SELECT_NONE or SELECT_PK) or one specific defined by thegiveQueries()method- Parameters:
queryid- Numeric id that identifies the specific queryvalues- Map that contains the values that will be associated to the parameters of the query (it can be null)maxrows- Maximum numer of rows to extract (0 if we want to extract ALL the rows)skiprows- Number of initial lines that you do not want to be returned. Even these lines, although skipped, are counted in the maxrows parameter.- Returns:
- A DBView that contains the data extracted by the query
-
query
Executes a query. The query is specified by a unique numeric id; it can be one of the predefined ids (like SELECT_FILTER, SELECT_NONE or SELECT_PK) or one specific defined by thegiveQueries()method- Parameters:
queryid- Numeric id that identifies the specific queryvalues- Map that contains the values that will be associated to the parameters of the query (it can be null)maxrows- Maximum numer of rows to extract (0 if we want to extract ALL the rows)conn- The connection which we use to do the query- Returns:
- A DBView that contains the data extracted by the query
-
query
public DBView query(int queryid, HashGetter values, int maxrows, int skiprows, PooledConnection conn) Executes a query. The query is specified by a unique numeric id; it can be one of the predefined ids (like SELECT_FILTER, SELECT_NONE or SELECT_PK) or one specific defined by thegiveQueries()method- Parameters:
queryid- Numeric id that identifies the specific queryvalues- Map that contains the values that will be associated to the parameters of the query (it can be null)maxrows- Maximum numer of rows to extract (0 if we want to extract ALL the rows)skiprows- Number of initial lines that you do not want to be returned. Even these lines, although skipped, are counted in the maxrows parameter.conn- The connection which we use to do the query- Returns:
- A DBView that contains the data extracted by the query
-
query
public DBView query(int queryid, HashGetter values, int maxrows, int skiprows, PooledConnection conn, DBStatementObserver observer) Executes a query. The query is specified by a unique numeric id; it can be one of the predefined ids (like SELECT_FILTER, SELECT_NONE or SELECT_PK) or one specific defined by thegiveQueries()method- Parameters:
queryid- Numeric id that identifies the specific queryvalues- Map that contains the values that will be associated to the parameters of the query (it can be null)maxrows- Maximum numer of rows to extract (0 if we want to extract ALL the rows)skiprows- Number of initial lines that you do not want to be returned. Even these lines, although skipped, are counted in the maxrows parameter.conn- The connection which we use to do the query; the connection must already have been extracted from a pool.observer- The DBStatementObserver that will receive the creation and release of the DBStatement- Returns:
- A DBView that contains the data extracted by the query
-
command
public int command(int commandId, HashGetter filter, HashGetter values) throws DAValidateException, DAException Executes a command. The command is specified by a unique numeric id; it can be one of the predefined ids (like DELETE_PK, UPDATE_PK and so on) or one specific defined by thegiveCommands()method- Parameters:
commandId- Numeric id that identifies the specific commandfilter- Map that contains the parmeters used to find the record on which we want to execute the command. If the command don't ness a filter we can use nullvalues- Map that contains the values that we want to apply to the selected records on which we want to execute the command. If the command don't need values, we can use null- Returns:
- An integer that indicates the number of record on which the command have act. Before the returning the method make a commit and release the connection to the pool
- Throws:
DAValidateException- If there are error in the pre-validation phase, a DAValidateException is thrown and the connection is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
command
public int command(int iCommandId, HashGetter filter, HashGetter values, PooledConnection conn) throws DAValidateException, DAException Executes a command. The command is specified by a unique numeric id; it can be one of the predefined ids (like DELETE_PK, UPDATE_PK and so on) or one specific defined by thegiveCommands()method- Parameters:
iCommandId- Numeric id that identifies the specific commandfilter- Map that contains the parmeters used to find the record on which we want to execute the command. If the command don't ness a filter we can use nullvalues- Map that contains the values that we want to apply to the selected records on which we want to execute the command. If the command don't need values, we can use nullconn- The connection which we use to do the command- Returns:
- An integer that indicates the number of record on which the command have act. Before the returning the method make a commit and release the connection to the pool
- Throws:
DAValidateException- DAValidateException If there are error in the pre-validation phase, a DAValidateException is thrown and the connection is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
command
public int command(int commandId, HashGetter filter, HashGetter values, PooledConnection conn, DBStatementObserver observer) throws DAValidateException, DAException Executes a command. The command is specified by a unique numeric id; it can be one of the predefined ids (like DELETE_PK, UPDATE_PK and so on) or one specific defined by thegiveCommands()method- Parameters:
commandId- Numeric id that identifies the specific commandfilter- Map that contains the parmeters used to find the record on which we want to execute the command. If the command don't ness a filter we can use nullvalues- Map that contains the values that we want to apply to the selected records on which we want to execute the command. If the command don't need values, we can use nullconn- The connection which we use to do the commandobserver- The DBStatementObserver that will receive the creation and release of the DBStatement- Returns:
- An integer that indicates the number of record on which the command have act. Before the returning the method make a commit and release the connection to the pool
- Throws:
DAValidateException- DAValidateException If there are error in the pre-validation phase, a DAValidateException is thrown and the connection is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
save
Takes aDBViewas parameter and performs on the database all the operation (insert, delete, update) that have been done on the DBView itself. At the end the method do a commit and makes the changes effective.- Parameters:
dbv- DBView that you want to save on the database- Returns:
- true if the save is succesful, false otherwise
- Throws:
DAValidateException- If there are errors in the pre-validation phase an exception is raised to the caller and the connection extracted from the pool is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
save
Takes aDBViewas parameter and performs on the database all the operation (insert, delete, update) that have been done on the DBView itself. At the end the method don't do a commit so the changes are not effective.- Parameters:
dbv- DBView that you want to save on the databaseconn- Connection which is used to make the operations. The connections must be already extracted form the pool- Returns:
- true if the save is succesful, false otherwise
- Throws:
DAValidateException- If there are errors in the pre-validation phase an exception is raised to the callerDAException- If there is a (blocking) data-access error, a DAException is thrown
-
replace
Saves the information contained in a DBView by performing an insert of all the DBView records after deleting those previously present in DB. At the end the method do a commit and makes the changes effective.- Parameters:
dbv- DBView that you want to save on the databasekeys- Array of strings that represents the keys used to delete the database records before the insert of the new ones- Returns:
- true if the save is successful, false otherwise
- Throws:
DAValidateException- If there are errors in the pre-validation phase an exception is raised to the caller and the connection extracted from the pool is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
replace
public boolean replace(DBView dbv, PooledConnection conn, String[] keys) throws DAValidateException, DAException Saves the information contained in a DBView by performing an insert of all the DBView records after deleting those previously present in DB. At the end the method do a commit and makes the changes effective.- Parameters:
dbv- DBView that you want to save on the databaseconn- Connection which is used to make the operations. The connections must be already extracted form the poolkeys- Array of strings that represents the keys used to delete the database records before the insert of the new ones- Returns:
- true if the save is successful, false otherwise
- Throws:
DAValidateException- If there are errors in the pre-validation phase an exception is raised to the caller and the connection extracted from the pool is closedDAException- If there is a (blocking) data-access error, a DAException is thrown
-
getDBFields
Makes a fetch on the table associated to the specific DA, to retrieve theDBFields, an ordered Field collection access by name- Returns:
- The DBFields of the table
-
getFieldMap
Deprecated.UsegetDBFields()instead, that makes a fetch on the table- Returns:
- Use
getDBFields()instead, that makes a fetch on the table
-
getAutoIncrementVal
protected Long getAutoIncrementVal(DBStatement insertDbs, PooledConnection conn) throws SQLException Retrieves the new id according to the specific DB. on other DBs we retrieve it with some query on the connection (mysql). If the value must be preset using a sequence (on oracle and postgres) the method will return null.- Parameters:
insertDbs- The statement used to retrieve the new idconn- The connection used to retrieve the new id- Returns:
- The new id (null if the value must be preset using a sequence)
- Throws:
SQLException- If there is an error in the SQL SQLException is thrown
-
getSequenceNextVal
Retrieves the new sequence value according to the specific DB.- Parameters:
conn- The connection used to retrieve the new value- Returns:
- The new sequence value
- Throws:
SQLException- If there is an error in the SQL SQLException is thrown
-
useConnection
Extracts a connection from the pool- Parameters:
poolName- Name of the pool from which we extract the connectioncmdId- Numeric id of the command- Returns:
- The connection extracted from the pool
-
release
Releases a connection and returns it to the pool from which it has been extracted- Parameters:
conn- The connection that must be released
-
getQueryId
Returns the id of the query passed as parameter- Parameters:
id- The name of the querydef- The default idda- The specific DA- Returns:
- The id of the query passed as parameters
-
getQueryId
Returns the id of the query passed as parameter- Parameters:
id- he name of the queryda- The specific DA- Returns:
- The id of the query passed as parameters
-
getDataAttributes
Description copied from interface:DataAttributesHolder- Specified by:
getDataAttributesin interfaceDataAttributesHolder- Returns:
- a
List<DataAttribute> about theEDMdata attributes.
-
setDataAttributes
Description copied from interface:DataAttributesHolderSets the provideddataAttributes.- Specified by:
setDataAttributesin interfaceDataAttributesHolder- Parameters:
dataAttributes-List<DataAttribute> about theEDMdata attributes to be set.
-
markAsDecorated
public void markAsDecorated()Description copied from interface:EDMConfigurableBeanMark thisEDMConfigurableBeanas already decorated withEDMconfiguration.- Specified by:
markAsDecoratedin interfaceEDMConfigurableBean
-
hasNotBeenDecorated
public boolean hasNotBeenDecorated()Description copied from interface:EDMConfigurableBeanReturnstruein case thisEDMConfigurableBeanhas not been already decorated withEDMconfiguration;falseotherwise.- Specified by:
hasNotBeenDecoratedin interfaceEDMConfigurableBean- Returns:
truein case thisEDMConfigurableBeanhas not been already decorated withEDMconfiguration;falseotherwise.
-
getDBFields()instead, that makes a fetch on the table