Package org.sqlproc.engine
Class SqlCrudEngine
- java.lang.Object
-
- org.sqlproc.engine.SqlEngine
-
- org.sqlproc.engine.SqlCrudEngine
-
public class SqlCrudEngine extends SqlEngine
The primary SQL Processor class for the META SQL CRUD statement execution.Instance of this class holds one META SQL statement.
For example there's a table PERSON with two columns - ID and NAME.
In the meta statements file statements.qry there's the next definition:UPDATE_PERSON(CRUD)= update PERSON {= set name = :name} {= where {& id = :id^long^notnull}} ;
In the case of the SQL Processor initialization
JdbcEngineFactory sqlFactory = new JdbcEngineFactory(); sqlFactory.setMetaFilesNames("statements.qry"); // the meta statements file SqlCrudEngine sqlEngine = sqlFactory.getCrudEngine("UPDATE_PERSON"); // for the case it runs on the top of the JDBC stack Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:sqlproc", "sa", ""); SqlSession session = new JdbcSimpleSession(connection);
there's created an instance of SqlCrudEngine with the nameUPDATE_PERSON
.Next the query can be executed with one of the
updateXXX
methods. For example there's a Java bean class Person with attributes id and name. The invocationPerson person = new Person(); person.setId(1); person.setName("Bozena"); int count = sqlEngine.update(session, person);
produces the next SQL executionupdate PERSON SET name = ? WHERE id = ?
and returns the number of updated rows.
For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
-
Field Summary
-
Fields inherited from class org.sqlproc.engine.SqlEngine
features, logger, mapping, monitor, name, pluginFactory, processingCache, processingCacheStatistics, statement, typeFactory, validator
-
-
Constructor Summary
Constructors Constructor Description SqlCrudEngine(String name, String statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement string.SqlCrudEngine(String name, String statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement string.SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance.SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory, SqlEngineConfiguration configuration)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance.SqlCrudEngine(String name, SqlMetaStatement statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance.SqlCrudEngine(String name, SqlMetaStatement statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Integer
delete(SqlQuery query, SqlProcessResult processResult)
Internal delete implementationint
delete(SqlSession session, Object dynamicInputValues)
Runs the META SQL delete statement to delete a database row.int
delete(SqlSession session, Object dynamicInputValues, Object staticInputValues)
Runs the META SQL delete statement to delete a database row.int
delete(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout)
Runs the META SQL delete statement to delete a database row.int
delete(SqlSession session, Object dynamicInputValues, SqlControl sqlControl)
Runs the META SQL delete statement to delete a database row.private <E> E
get(SqlQuery query, SqlMappingResult mappingResult, Class<E> resultClass, SqlControl sqlControl)
Internal get implementation<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues)
Runs the META SQL query to obtain a unique database row.<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues)
Runs the META SQL query to obtain a unique database row.<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout)
Runs the META SQL query to obtain a unique database row.<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout, Map<String,Class<?>> moreResultClasses)
Runs the META SQL query to obtain a unique database row.<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, Map<String,Class<?>> moreResultClasses)
Runs the META SQL query to obtain a unique database row.<E> E
get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, SqlControl sqlControl)
Runs the META SQL query to obtain a unique database row.String
getDeleteSql(Object dynamicInputValues, Object staticInputValues)
Returns the delete statement derived from the META SQL statement.String
getGetSql(Object dynamicInputValues, Object staticInputValues)
Returns the query select statement derived from the META SQL statement.String
getInsertSql(Object dynamicInputValues, Object staticInputValues)
Returns the insert statement derived from the META SQL statement.SqlMonitor
getMonitor()
Returns the SQL Monitor instance for the runtime statistics gathering.String
getName()
Returns the name of this META SQL, which uniquely identifies the instance.String
getSql(Object dynamicInputValues, Object staticInputValues, SqlMetaStatement.Type statementType)
Because SQL Processor is Data Driven Query engine, every input parameters can produce in fact different SQL statement command.String
getSql(Object dynamicInputValues, SqlControl sqlControl, SqlMetaStatement.Type statementType)
Because SQL Processor is Data Driven Query engine, every input parameters can produce in fact different SQL statement command.String
getUpdateSql(Object dynamicInputValues, Object staticInputValues)
Returns the update statement derived from the META SQL statement.private Integer
insert(SqlQuery query, SqlProcessResult processResult)
Internal insert implementationint
insert(SqlSession session, Object dynamicInputValues)
Runs the META SQL insert statement to persist a database row.int
insert(SqlSession session, Object dynamicInputValues, Object staticInputValues)
Runs the META SQL insert statement to persist a database row.int
insert(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout)
Runs the META SQL insert statement to persist a database row.int
insert(SqlSession session, Object dynamicInputValues, SqlControl sqlControl)
Runs the META SQL insert statement to persist a database row.private Integer
update(SqlQuery query, SqlProcessResult processResult)
Internal update implementationint
update(SqlSession session, Object dynamicInputValues)
Runs the META SQL update statement to persist a database row.int
update(SqlSession session, Object dynamicInputValues, Object staticInputValues)
Runs the META SQL update statement to persist a database row.int
update(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout)
Runs the META SQL update statement to persist a database row.int
update(SqlSession session, Object dynamicInputValues, SqlControl sqlControl)
Runs the META SQL update statement to persist a database row.-
Methods inherited from class org.sqlproc.engine.SqlEngine
checkDynamicInputValues, checkStaticInputValues, getDynamicUpdateValues, getFeatures, getFeatures, getFetchSize, getFirstResult, getMaxResults, getMaxTimeout, getMoreResultClasses, getOrder, getPluginFactory, getProcessingCache, getProcessingCacheStatistics, getStaticInputValues, getTypeFactory, isSkipEmptyStatement, process, setFeature, setProcessingCache, setProcessingCacheStatistics, setValidator, unsetFeatures
-
-
-
-
Constructor Detail
-
SqlCrudEngine
public SqlCrudEngine(String name, String statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory) throws SqlEngineException
Creates a new instance of the SqlCrudEngine from one META SQL statement string. Constructor will call the internal ANTLR parser for the CRUD statement construction. This constructor is devoted to manual META SQL statements construction. More obvious is to put the META SQL statements definitions into the meta statements file and engage theSqlProcessorLoader
for the SqlCrudEngine instances construction.- Parameters:
name
- the name of this SQL Engine instancestatement
- the META SQL CRUD statementtypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor plugins- Throws:
SqlEngineException
- in the case the provided statements are not compliant with the ANTLR grammar
-
SqlCrudEngine
public SqlCrudEngine(String name, String statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory) throws SqlEngineException
Creates a new instance of the SqlCrudEngine from one META SQL statement string. Constructor will call the internal ANTLR parser for the CRUD statement instances construction. Compared to the previous constructor, an external SQL Monitor for the runtime sSqlValidationExceptiontatistics gathering is engaged and the optional features can be involved. This constructor is devoted to manual META SQL statements construction. More obvious is to put the META SQL statements definitions into the meta statements file and engage theSqlProcessorLoader
for the SqlCrudEngine instances construction.- Parameters:
name
- the name of this SQL Engine instancestatement
- the META SQL CRUD statementmonitor
- the SQL Monitor for the runtime statistics gatheringfeatures
- the optional SQL Processor featurestypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor plugins- Throws:
SqlEngineException
- in the case the provided statements are not compliant with the ANTLR grammar
-
SqlCrudEngine
public SqlCrudEngine(String name, SqlMetaStatement statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance. This instance is already pre-compiled using the ANTLR parser. This is the recommended usage for the runtime performance optimization. This constructor is devoted to be used from the custom loader, which is able to read all statements definitions from an external meta statements file and create the named SqlCrudEngine instances.- Parameters:
name
- the name of this SQL Engine instancestatement
- the pre-compiled META SQL CRUD statementtypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor plugins
-
SqlCrudEngine
public SqlCrudEngine(String name, SqlMetaStatement statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance. This instance is already pre-compiled using the ANTLR parsers. This is the recommended usage for the runtime performance optimization. This constructor is devoted to be used from the custom loader, which is able to read all statements definitions from an external meta statements file and create the named SqlCrudEngine instances. Compared to the previous constructor, an external SQL Monitor for the runtime statistics gathering is engaged and the optional features can be involved.- Parameters:
name
- the name of this SQL Engine instancestatement
- the pre-compiled META SQL CRUD statementmonitor
- the SQL Monitor for the runtime statistics gatheringfeatures
- the optional SQL Processor featurestypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor plugins
-
SqlCrudEngine
public SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance. This instance is already pre-compiled using the ANTLR parsers. This is the recommended usage for the runtime performance optimization. This constructor is devoted to be used from the custom loader, which is able to read all statements definitions from an external meta statements file and create the named SqlCrudEngine instances. Compared to the previous constructor, an external SQL Monitor for the runtime statistics gathering is engaged and the optional features can be involved.- Parameters:
name
- the name of this SQL Engine instancestatement
- the pre-compiled META SQL CRUD statementmapping
- the pre-compiled SQL mapping rulemonitor
- the SQL Monitor for the runtime statistics gatheringfeatures
- the optional SQL Processor featurestypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor plugins
-
SqlCrudEngine
public SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory, SqlEngineConfiguration configuration)
Creates a new instance of the SqlCrudEngine from one META SQL statement instance. This instance is already pre-compiled using the ANTLR parsers. This is the recommended usage for the runtime performance optimization. This constructor is devoted to be used from the custom loader, which is able to read all statements definitions from an external meta statements file and create the named SqlCrudEngine instances. Compared to the previous constructor, an external SQL Monitor for the runtime statistics gathering is engaged and the optional features can be involved.- Parameters:
name
- the name of this SQL Engine instancestatement
- the pre-compiled META SQL CRUD statementmapping
- the pre-compiled SQL mapping rulemonitor
- the SQL Monitor for the runtime statistics gatheringfeatures
- the optional SQL Processor featurestypeFactory
- the factory for the META types constructionpluginFactory
- the factory for the SQL Processor pluginsconfiguration
- the overall configuration, which can be persisted
-
-
Method Detail
-
insert
public int insert(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL insert statement to persist a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodinsert(SqlSession, Object, Object, int)
.
-
insert
public int insert(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL insert statement to persist a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodinsert(SqlSession, Object, Object, int)
.
-
insert
public int insert(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL insert statement to persist a database row. This is the primary and the most complex SQL Processor execution method to persist an instance of input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.staticInputValues
- The object used for the SQL statement static input values. The class of this object is also named as the input class or the static parameters class. The exact class type isn't important, all the parameters injected into the SQL query command are picked up using the reflection API. Compared to dynamicInputValues input parameters, parameters in this class should't be produced by an end user to prevent SQL injection threat!maxTimeout
- The max SQL execution time. This parameter can help to protect production system against ineffective SQL query commands. The value is in milliseconds.- Returns:
- The number of persisted database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
insert
public int insert(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException, SqlValidationException
Runs the META SQL insert statement to persist a database row. This is the primary and the most complex SQL Processor execution method to persist an instance of input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.sqlControl
- The compound parameters controlling the META SQL execution- Returns:
- The number of persisted database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handlingSqlValidationException
- in the case the validation of the input values isn't successfull
-
insert
private Integer insert(SqlQuery query, SqlProcessResult processResult)
Internal insert implementation- Parameters:
query
- queryprocessResult
- processResult- Returns:
- the result
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodget(SqlSession, Class, Object, Object, int, Map)
.
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodget(SqlSession, Class, Object, Object, int, Map)
.
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, Map<String,Class<?>> moreResultClasses) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodget(SqlSession, Class, Object, Object, int, Map)
.
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodget(SqlSession, Class, Object, Object, int, Map)
.
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout, Map<String,Class<?>> moreResultClasses) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is the primary and the most complex SQL Processor execution method to obtain an unique instance of the result class. Criteria to pickup the correct database row are taken from input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.resultClass
- The class used for the return values, the SQL query execution output. This class is also named as the output class or the transport class, In fact it's a standard POJO class, which must include all the attributes described in the mapping rule statement. This class itself and all its subclasses must have public constructors without any parameters. All the attributes used in the mapping rule statement must be accessible using public getters and setters. The instances of this class are created on the fly in the process of query execution using the reflection API.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.staticInputValues
- The object used for the SQL statement static input values. The class of this object is also named as the input class or the static parameters class. The exact class type isn't important, all the parameters injected into the SQL query command are picked up using the reflection API. Compared to dynamicInputValues input parameters, parameters in this class should't be produced by an end user to prevent SQL injection threat!maxTimeout
- The max SQL execution time. This parameter can help to protect production system against ineffective SQL query commands. The value is in milliseconds.moreResultClasses
- More result classes used for the return values, like the collections classes or the collections items. They are used mainly for the one-to-one, one-to-many and many-to-many associations.- Returns:
- The instance of the resultClass.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
get
public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL query to obtain a unique database row. This is the primary and the most complex SQL Processor execution method to obtain an unique instance of the result class. Criteria to pickup the correct database row are taken from input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.resultClass
- The class used for the return values, the SQL query execution output. This class is also named as the output class or the transport class, In fact it's a standard POJO class, which must include all the attributes described in the mapping rule statement. This class itself and all its subclasses must have public constructors without any parameters. All the attributes used in the mapping rule statement must be accessible using public getters and setters. The instances of this class are created on the fly in the process of query execution using the reflection API.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.sqlControl
- The compound parameters controlling the META SQL execution- Returns:
- The instance of the resultClass.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
get
private <E> E get(SqlQuery query, SqlMappingResult mappingResult, Class<E> resultClass, SqlControl sqlControl)
Internal get implementation- Parameters:
query
- querymappingResult
- mappingResultresultClass
- resultClasssqlControl
- sqlCOntrol- Returns:
- the result
-
update
public int update(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL update statement to persist a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodupdate(SqlSession, Object, Object, int)
.
-
update
public int update(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL update statement to persist a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methodupdate(SqlSession, Object, Object, int)
.
-
update
public int update(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL update statement to persist a database row. This is the primary and the most complex SQL Processor execution method to persist an instance of input values. Changed values are taken from the input values. At the same time criteria to pickup the correct database rows(s) are taken from the input values too.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.staticInputValues
- The object used for the SQL statement static input values. The class of this object is also named as the input class or the static parameters class. The exact class type isn't important, all the parameters injected into the SQL query command are picked up using the reflection API. Compared to dynamicInputValues input parameters, parameters in this class should't be produced by an end user to prevent SQL injection threat!maxTimeout
- The max SQL execution time. This parameter can help to protect production system against ineffective SQL query commands. The value is in milliseconds.- Returns:
- The number of updated database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
update
public int update(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException, SqlValidationException
Runs the META SQL update statement to persist a database row. This is the primary and the most complex SQL Processor execution method to persist an instance of input values. Changed values are taken from the input values. At the same time criteria to pickup the correct database rows(s) are taken from the input values too.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.sqlControl
- The compound parameters controlling the META SQL execution- Returns:
- The number of updated database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handlingSqlValidationException
- in the case the validation of the input values isn't successfull
-
update
private Integer update(SqlQuery query, SqlProcessResult processResult)
Internal update implementation- Parameters:
query
- query- Returns:
- the result
-
delete
public int delete(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL delete statement to delete a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methoddelete(SqlSession, Object, Object, int)
.
-
delete
public int delete(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL delete statement to delete a database row. This is one of the overriden methods. For the parameters description please see the most complex execution methoddelete(SqlSession, Object, Object, int)
.
-
delete
public int delete(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL delete statement to delete a database row. This is the primary and the most complex SQL Processor execution method to delete the database row(s) based on criteria from the input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.staticInputValues
- The object used for the SQL statement static input values. The class of this object is also named as the input class or the static parameters class. The exact class type isn't important, all the parameters injected into the SQL query command are picked up using the reflection API. Compared to dynamicInputValues input parameters, parameters in this class should't be produced by an end user to prevent SQL injection threat!maxTimeout
- The max SQL execution time. This parameter can help to protect production system against ineffective SQL query commands. The value is in milliseconds.- Returns:
- The number of updated database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
delete
public int delete(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException
Runs the META SQL delete statement to delete a database row. This is the primary and the most complex SQL Processor execution method to delete the database row(s) based on criteria from the input values.- Parameters:
session
- The SQL Engine session. It can work as a first level cache and the SQL query execution context. The implementation depends on the stack, on top of which the SQL Processor works. For example it can be an Hibernate session.dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.sqlControl
- The compound parameters controlling the META SQL execution- Returns:
- The number of updated database rows.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
delete
private Integer delete(SqlQuery query, SqlProcessResult processResult)
Internal delete implementation- Parameters:
query
- query- Returns:
- the result
-
getInsertSql
public String getInsertSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Returns the insert statement derived from the META SQL statement. For the parameters description please see the most complex execution methodgetSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
-
getGetSql
public String getGetSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Returns the query select statement derived from the META SQL statement. For the parameters description please see the most complex execution methodgetSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
-
getUpdateSql
public String getUpdateSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Returns the update statement derived from the META SQL statement. For the parameters description please see the most complex execution methodgetSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
-
getDeleteSql
public String getDeleteSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
Returns the delete statement derived from the META SQL statement. For the parameters description please see the most complex execution methodgetSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
-
getSql
public String getSql(Object dynamicInputValues, Object staticInputValues, SqlMetaStatement.Type statementType) throws SqlProcessorException, SqlRuntimeException
Because SQL Processor is Data Driven Query engine, every input parameters can produce in fact different SQL statement command. This method can help to identify the exact SQL statement command, which is produced in the background of the SQL Processor execution. The statement is derived from the META SQL statement.- Parameters:
dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.staticInputValues
- The object used for the SQL statement static input values. The class of this object is also named as the input class or the static parameters class. The exact class type isn't important, all the parameters injected into the SQL query command are picked up using the reflection API. Compared to dynamicInputValues input parameters, parameters in this class should't be produced by an end user to prevent SQL injection threat!statementType
- The type of the statement under consideration. It can be CREATE, RETRIEVE, UPDATE or DELETE.- Returns:
- The SQL statement command derived from the META SQL statement based on the input parameters.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
getSql
public String getSql(Object dynamicInputValues, SqlControl sqlControl, SqlMetaStatement.Type statementType) throws SqlProcessorException, SqlRuntimeException
Because SQL Processor is Data Driven Query engine, every input parameters can produce in fact different SQL statement command. This method can help to identify the exact SQL statement command, which is produced in the background of the SQL Processor execution. The statement is derived from the META SQL statement.- Parameters:
dynamicInputValues
- The object used for the SQL statement dynamic input values. The class of this object is also named as the input class or the dynamic parameters class. The exact class type isn't important, all the parameters settled into the SQL prepared statement are picked up using the reflection API.sqlControl
- The compound parameters controlling the META SQL executionstatementType
- The type of the statement under consideration. It can be CREATE, RETRIEVE, UPDATE or DELETE.- Returns:
- The SQL statement command derived from the META SQL statement based on the input parameters.
- Throws:
SqlProcessorException
- in the case of any problem with ORM or JDBC stackSqlRuntimeException
- in the case of any problem with the input/output values handling
-
getName
public String getName()
Returns the name of this META SQL, which uniquely identifies the instance. In the case the META SQL statement is located in the meta statements file, this name is the unique part of the keys in this file. For example for the name ALL in the meta statements file there's the META SQL statement with the name ALL(CRUD).- Returns:
- The name of the SQL engine instance.
-
getMonitor
public SqlMonitor getMonitor()
Returns the SQL Monitor instance for the runtime statistics gathering. By default no runtime statistics gathering is active. So this SQL Monitor is implied in SQL engine constructor in the case the statistics gathering should be engaged.- Returns:
- The SQL Monitor instance, which is active for this SQL engine instance.
-
-