Package overit.geocall.da
Class DAO0
java.lang.Object
overit.geocall.da.DAO0
- All Implemented Interfaces:
Serializable,overit.geocall.marks.FieldExposer,overit.geocall.marks.NameExposer,DBFieldMapper,DBObjectMapper,Identified
- Direct Known Subclasses:
overit.geocallapp.wfm.workorder.scheduling.DAOIntervention,DAONotifications,DAOUserState,overit.geocallapp.wfm.schedulazione.anagrafiche.tipiodltestate.DAOWOTypes
@Deprecated
public class DAO0
extends Object
implements DBFieldMapper, DBObjectMapper, Identified, overit.geocall.marks.FieldExposer, overit.geocall.marks.NameExposer, Serializable
Deprecated.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DBFieldMapDeprecated.protected DBObjectMapDeprecated.static final CommandDeprecated.StandardCommandthat deletes a record, using the filter passed to theCommandContextstatic final CommandDeprecated.StandardCommandthat deletes a record, using the primary key field passed to theCommandContextstatic final CommandDeprecated.static final CommandDeprecated.StandardCommandthat inserts a new recordstatic final CommandDeprecated.StandardCommandthat tries to insert a new record; if the insert fails, returns the value 0 and not an errorstatic final CommandDeprecated.StandardCommandthat implements the query: SELECT * FROM TABLE WHERE ... = ?static final CommandDeprecated.StandardCommandthat implements the empty query: SELECT * FROM TABLE WHERE 1 = 0static final CommandDeprecated.StandardCommandthat implements the query: SELECT * FROM TABLE WHERE PRIMARY_KEY = ?static final CommandDeprecated.StandardCommandthat updates a record, using the filter passed to theCommandContextstatic final CommandDeprecated.StandardCommandthat updates a record, using the primary key passed to theCommandContextstatic final CommandDeprecated.Standard UPSERTCommand: tries to make an update, if fails do an insert -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintDeprecated.Executes the command defined by theCommandContextpassed as parameterintcommand(CommandContext cc, PooledConnection pc) Deprecated.Executes the command defined by theCommandContextpassed as parameterfinal CommandcommandForName(String name) Deprecated.Returns theCommandthat corresponds to the query or command name passed as parameterprotected voidDeprecated.The method performs a cloning of the maps of the filters and of the values and makes a merge, putting before the filter field names the string F: and before the value field names the string V: to avoid possible conflicts; this is necessary because the same field can be used with different semantics, as a filter and as a value, for example for theUPDATE_FILTERcommandsprotected voiddefineSql(CommandContext cc, PooledConnection pc) Deprecated.The method creates the SQL command using the language of the criteria, and in particular based on the methodgetFilterCriterion(CommandContext)protected voiddefineStatement(CommandContext cc, PooledConnection pc, DBStatement dbs) Deprecated.The method defines theDBStatement, sets the SQL and the parameters for the execution of the commandsprotected voidDeprecated.Method to extend to go to prepare the values operating Java side, for example making calculations, avoiding to operate SQL side that is much more difficult, inconvenient, difficult to maintain and not portable.voidDeprecated.Executes the command; it extracts a newPooledConnectionfrom the poolvoidexecute(CommandContext cc, PooledConnection pc) Deprecated.Executes the commandprotected voidfeedback(CommandContext cc, PooledConnection pc, DBStatement dbs) Deprecated.Method to be extended to carry out operations exploiting the result of the executed command; for example it can be used to implement CASE WHEN logics that can therefore be deleted from the SQL.Deprecated.Returns the name of the field of the table in which is stored the "branch id" value, set with the Branch annotationDeprecated.Returns theDBFieldMapobjectDeprecated.Returns theDBObjectMapcontained in the instanceDeprecated.Returns the name of the field of the table in which is stored the "factory id" value, set with the Factory annotationprotected CriterionDeprecated.Method to extend to go to introduce the inferential rules with which to deduce the SQL automatically based on the context passed as a parameter.String[]Deprecated.Returns the array that contains the names of the columns on which we want to group the reults of the queries.Deprecated.Returns theIdentityassociated to the componentgetLevel()Deprecated.Returns the name of the field of the table in which is stored the "level" value, so that the optimistic lock can be managed.String[]Deprecated.Returns the array that contains the names of the columns on which we want to make the sorting of the results of the queries.String[]getPk()Deprecated.Returns the array that contains the primary keys of the specific table on which the DAO acts.getPool()Deprecated.Returns the name of the pool from which the specific DAO extracts the connections when they are not explicitly passed to methods.Deprecated.Returns a string that represent the name of the field used as sequence for the insert commands on the table.String[]Deprecated.Returns the array that contains the field list for all the select queries.Deprecated.Returns the name of the table on which the specific DAO actsDeprecated.Returns theTeacherused for the translations by the DAOprotected CriterionDeprecated.Method that defines theCriterionused for the different commandsbooleanDeprecated.Checks if there is a correctDBFieldMapobjectbooleanDeprecated.Checks the presence of a validDBObjectMapcontained in the instance.booleanDeprecated.Returns the boolean value that determines whether the queries use the DISTINCT clause or notbooleanDeprecated.Returns the boolean value that determines whether connection extraction takes place from the standard pool or the service poolquery(CommandContext cc) Deprecated.Executes the query defined by theCommandContextpassed as parameterquery(CommandContext cc, PooledConnection pc) Deprecated.Executes the query defined by theCommandContextpassed as parametervoidsetDBFieldMap(DBFieldMap dbfm) Deprecated.Sets theDBFieldMapobjectvoidsetDBObjectMap(DBObjectMap dbom) Deprecated.Sets theDBObjectMapcontained in the instancevoidsetIdentity(Identity identity) Deprecated.Sets theIdentityto the componentprotected voidvalidate(CommandContext cc, PooledConnection pc) Deprecated.Method to extend if you want to implement some logic of data validation; it can raise a DAException, or better, a DAValidateException.
-
Field Details
-
SELECT_FILTER
Deprecated.StandardCommandthat implements the query: SELECT * FROM TABLE WHERE ... = ? -
SELECT_NONE
Deprecated.StandardCommandthat implements the empty query: SELECT * FROM TABLE WHERE 1 = 0 -
SELECT_PK
Deprecated.StandardCommandthat implements the query: SELECT * FROM TABLE WHERE PRIMARY_KEY = ? -
DELETE_FILTER
Deprecated.StandardCommandthat deletes a record, using the filter passed to theCommandContext -
DELETE_PK
Deprecated.StandardCommandthat deletes a record, using the primary key field passed to theCommandContext -
UPDATE_FILTER
Deprecated.StandardCommandthat updates a record, using the filter passed to theCommandContext -
UPDATE_PK
Deprecated.StandardCommandthat updates a record, using the primary key passed to theCommandContext -
INSERT
Deprecated.StandardCommandthat inserts a new record -
INSERT_ATTEMPT
Deprecated.StandardCommandthat tries to insert a new record; if the insert fails, returns the value 0 and not an error -
UPSERT
Deprecated.Standard UPSERTCommand: tries to make an update, if fails do an insert -
INSATE
Deprecated.useDAO.UPSERT,DAO.INSERTorDAO.UPDATE_PKaccording to your needs. The correct functioning of thisCommandon all databases is not guaranteed (Postgres aborts the transaction if the INSERT raises a unique constraint violation, and the subsequent UPDATE will fail).Standard INSATECommand: tries to make an insert with theINSERT_ATTEMPT, if obtains 0 (meaning that the insert has failed) do an update -
_dbfm
Deprecated. -
_dbom
Deprecated.
-
-
Constructor Details
-
DAO0
public DAO0()Deprecated.
-
-
Method Details
-
commandForName
Deprecated.Returns theCommandthat corresponds to the query or command name passed as parameter- Parameters:
name- The string that defines the name of a query or command- Returns:
- The instance of
Commandthat corresponds to the string passed as parameter ornullif there isn't such Command, or an exception occurs
-
getTeacher
Deprecated.Returns theTeacherused for the translations by the DAO- Returns:
- The
Teacherinstance associated to the DAO
-
getDBFieldMap
Deprecated.Description copied from interface:DBFieldMapperReturns theDBFieldMapobject- Specified by:
getDBFieldMapin interfaceDBFieldMapper- Returns:
- The map used for the transformations of fields names
-
setDBFieldMap
Deprecated.Description copied from interface:DBFieldMapperSets theDBFieldMapobject- Specified by:
setDBFieldMapin interfaceDBFieldMapper- Parameters:
dbfm- The map used for the transformations of fields names
-
haveDBFieldMap
public boolean haveDBFieldMap()Deprecated.Description copied from interface:DBFieldMapperChecks if there is a correctDBFieldMapobject- Specified by:
haveDBFieldMapin interfaceDBFieldMapper- Returns:
trueif there is a correct DBFieldMap,falseotherwise
-
getDBObjectMap
Deprecated.Description copied from interface:DBObjectMapperReturns theDBObjectMapcontained in the instance- Specified by:
getDBObjectMapin interfaceDBObjectMapper- Returns:
- The map of objects used in this instance
-
setDBObjectMap
Deprecated.Description copied from interface:DBObjectMapperSets theDBObjectMapcontained in the instance- Specified by:
setDBObjectMapin interfaceDBObjectMapper- Parameters:
dbom- The map of objects used in this instance
-
haveDBObjectMap
public boolean haveDBObjectMap()Deprecated.Description copied from interface:DBObjectMapperChecks the presence of a validDBObjectMapcontained in the instance.- Specified by:
haveDBObjectMapin interfaceDBObjectMapper- Returns:
- true if the instance contains a map of object that is not null, false otherwise
-
getIdentity
Deprecated.Description copied from interface:IdentifiedReturns theIdentityassociated to the component- Specified by:
getIdentityin interfaceIdentified- Returns:
- The Identity of the user currently logged in the application
-
setIdentity
Deprecated.Description copied from interface:IdentifiedSets theIdentityto the component- Specified by:
setIdentityin interfaceIdentified- Parameters:
identity- The Identity that must be associated to the component
-
getFactory
Deprecated.Returns the name of the field of the table in which is stored the "factory id" value, set with the Factory annotation- Returns:
- The string that represents the name of the field of the table in which is stored the "factory id" value, that is, the foreign key to the factories table
-
getBranch
Deprecated.Returns the name of the field of the table in which is stored the "branch id" value, set with the Branch annotation- Returns:
- The string that represents the name of the field of the table in which is stored the "branch id" value, that is, the foreign key to the branches table
-
getPool
Deprecated.Returns the name of the pool from which the specific DAO extracts the connections when they are not explicitly passed to methods.- Returns:
- The name of the pool, as indicated in the configuration file, from which the specific DAO extracts the connections.
-
getPk
Deprecated.Returns the array that contains the primary keys of the specific table on which the DAO acts.- Returns:
- Array that contains the names of the fields that are primary keys of the specific table
-
getSequence
Deprecated.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
-
isService
public boolean isService()Deprecated.Returns the boolean value that determines whether connection extraction takes place from the standard pool or the service pool- Returns:
falsefor ordinary connection extraction,truefor ServicePool extraction
-
isDistinct
Deprecated.Returns the boolean value that determines whether the queries use the DISTINCT clause or not- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
trueif the queries use the DISTINCT,falseotherwise
-
getStar
Deprecated.Returns the array that contains the field list for all the select queries.- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
- The array of strings that represents the names of the columns to be extracted;
the default value is the array consisting of a single element, the character
*
-
getTable
Deprecated.Returns the name of the table on which the specific DAO acts- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
- The string that represents the name of the table on which the DAO want to access and operate
-
getLevel
Deprecated.Returns the name of the field of the table in which is stored the "level" value, so that the optimistic lock can be managed.- Returns:
- The
Stringabout the name of the field of the table in which is stored the "level" value, so that the optimistic lock can be managed.
-
getOrder
Deprecated.Returns the array that contains the names of the columns on which we want to make the sorting of the results of the queries.
The method checks for the presence of a sort string in theCommandContext, the one returned by theCommandContext.getOrder()method; the default implementation interprets the string as a comma-separated list of field names on which you want to sort query results. The presence of the exclamation point in front of a field name defines the will to order in a descending direction with respect to that field.
The extensions of this method can define their own grammar for the received string.
If there is no sort string in the CommandContext, the fields are searched using the annotation Group- Parameters:
cc- The {CommandContext} associated to the DAO- Returns:
- The array of strings that represents the name of the columns, and the corresponding sorting verse, used for the sorting of the results of the queries;
-
getGroup
Deprecated.Returns the array that contains the names of the columns on which we want to group the reults of the queries.- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
- The array of strings that represents the name of the columns used for the grouping of the results of the queries
-
getFilterCriterion
Deprecated.Method to extend to go to introduce the inferential rules with which to deduce the SQL automatically based on the context passed as a parameter.- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
- The
Criterionused to create the SQL By default the method returns theCriteria.SEARCH_STRONGfor the commands that refers to key fields and theCriteria.SEARCHfor all the other commands.
-
getValuesCriterion
Deprecated.Method that defines theCriterionused for the different commands- Parameters:
cc- TheCommandContextassociated to the DAO- Returns:
Criteria.INSERT_ASSIGNfor theCommand.Type.INSERTcommands,Criteria.UPDATE_ASSIGNfor theCommand.Type.UPDATEcommands
-
execute
Deprecated.Executes the command; it extracts a newPooledConnectionfrom the pool- Parameters:
cc- TheCommandContextassociated to the DAO- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
execute
Deprecated.Executes the command- Parameters:
cc- TheCommandContextassociated to the DAO; it can't be nullpc- ThePooledConnectionused to connect to the database; it can't be null- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
query
Deprecated.Executes the query defined by theCommandContextpassed as parameter- Parameters:
cc- TheCommandContextassociated to the DAO;- Returns:
- The
DBViewthat contains the records extracted - Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
query
Deprecated.Executes the query defined by theCommandContextpassed as parameter- Parameters:
cc- TheCommandContextassociated to the DAO;pc- ThePooledConnectionused to connect to the database;- Returns:
- The
DBViewthat contains the records extracted - Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
command
Deprecated.Executes the command defined by theCommandContextpassed as parameter- Parameters:
cc- TheCommandContextassociated to the DAO;pc- ThePooledConnectionused to connect to the database;- Returns:
- The number of records that have been entered, modified or deleted
- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
command
Deprecated.Executes the command defined by theCommandContextpassed as parameter- Parameters:
cc- TheCommandContextassociated to the DAO;- Returns:
- The number of records that have been entered, modified or deleted
- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
validate
protected void validate(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException Deprecated.Method to extend if you want to implement some logic of data validation; it can raise a DAException, or better, a DAValidateException. By default the method verifies that, if the command requested is a command that refers to a key field, that key field has been defined for the DAO and that the key field is among those passed as filter.- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connections- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
defineValues
protected void defineValues(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException Deprecated.Method to extend to go to prepare the values operating Java side, for example making calculations, avoiding to operate SQL side that is much more difficult, inconvenient, difficult to maintain and not portable. Changing the values in this method can have a return in the application mask, since the same map of values is used, and not a clone of it. By default the method sets the correct values for the sequence, the datastamp and login, where necessary.- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connections- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
defineParams
protected void defineParams(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException Deprecated.The method performs a cloning of the maps of the filters and of the values and makes a merge, putting before the filter field names the string F: and before the value field names the string V: to avoid possible conflicts; this is necessary because the same field can be used with different semantics, as a filter and as a value, for example for theUPDATE_FILTERcommands- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connections- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
defineSql
protected void defineSql(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException Deprecated.The method creates the SQL command using the language of the criteria, and in particular based on the methodgetFilterCriterion(CommandContext)- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connections- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
defineStatement
protected void defineStatement(CommandContext cc, PooledConnection pc, DBStatement dbs) throws DAException, DAValidateException Deprecated.The method defines theDBStatement, sets the SQL and the parameters for the execution of the commands- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connectionsdbs- TheDBStatementthat is used to access the database- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
feedback
protected void feedback(CommandContext cc, PooledConnection pc, DBStatement dbs) throws DAException, DAValidateException Deprecated.Method to be extended to carry out operations exploiting the result of the executed command; for example it can be used to implement CASE WHEN logics that can therefore be deleted from the SQL. The standard makes recursive calls for the correct execution of theUPSERTandINSATEoperations- Parameters:
cc- TheCommandContextassociated to the DAOpc- ThePooledConnectionfrom which extract the connectionsdbs- TheDBStatementthat is used to access the database- Throws:
DAException- If there is a (blocking) data-access error, a DAException must be thrownDAValidateException- If there are error in the validation phase, a DAValidateException must be thrown
-
DAOinstead Class to extend when you want to create an object that accesses a table of the database. The goal of the class is to avoid writing SQL and going to build inferential rules that, based on the parameter map passed, can deduce the SQL code to be created. To use the class you need to extend it and using the annotation that gives the fundamental information of the table that you want to map.This class implements some basic functions such the selection of one or all the table records or the deletion, insertion or updating of a record.
The methods that can be extended to create the desired logic are:
validate(CommandContext, PooledConnection)to perform a validation on the data,defineValues(CommandContext, PooledConnection)to set up the values,getFilterCriterion(CommandContext)to insert theCriteriathat will build the SQL code andfeedback(CommandContext, PooledConnection, DBStatement)to manage the results.