public class SqlCrudEngine extends SqlEngine
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 name UPDATE_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 invocation
Person person = new Person();
person.setId(1);
person.setName("Bozena");
int count = sqlEngine.update(session, person);
produces the next SQL execution
update PERSON SET name = ? WHERE id = ?
and returns the number of updated rows.
For more info please see the Tutorials.
features, logger, mapping, monitor, name, pluginFactory, processingCache, processingCacheStatistics, statement, typeFactory, validator| Constructor and Description |
|---|
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.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
private Integer |
delete(SqlQuery query,
SqlProcessResult processResult)
Internal delete implementation
|
int |
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 implementation
|
int |
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 implementation
|
int |
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.
|
checkDynamicInputValues, checkStaticInputValues, getDynamicUpdateValues, getFeatures, getFeatures, getFetchSize, getFirstResult, getMaxResults, getMaxTimeout, getMoreResultClasses, getOrder, getPluginFactory, getProcessingCache, getProcessingCacheStatistics, getStaticInputValues, getTypeFactory, isSkipEmptyStatement, process, setFeature, setProcessingCache, setProcessingCacheStatistics, setValidator, unsetFeaturespublic SqlCrudEngine(String name, String statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory) throws SqlEngineException
SqlProcessorLoader for the SqlCrudEngine instances construction.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 pluginsSqlEngineException - in the case the provided statements are not compliant with the ANTLR grammarpublic SqlCrudEngine(String name, String statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory) throws SqlEngineException
SqlProcessorLoader for the SqlCrudEngine instances construction.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 pluginsSqlEngineException - in the case the provided statements are not compliant with the ANTLR grammarpublic SqlCrudEngine(String name, SqlMetaStatement statement, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
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 pluginspublic SqlCrudEngine(String name, SqlMetaStatement statement, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
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 pluginspublic SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
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 pluginspublic SqlCrudEngine(String name, SqlMetaStatement statement, SqlMappingRule mapping, SqlMonitor monitor, Map<String,Object> features, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory, SqlEngineConfiguration configuration)
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 persistedpublic int insert(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
insert(SqlSession, Object, Object, int) .public int insert(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
insert(SqlSession, Object, Object, int) .public int insert(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic int insert(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException, SqlValidationException
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 executionSqlProcessorException - 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 successfullprivate Integer insert(SqlQuery query, SqlProcessResult processResult)
query - queryprocessResult - processResultpublic <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, Map<String,Class<?>> moreResultClasses) throws SqlProcessorException, SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .public <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, Object staticInputValues, int maxTimeout, Map<String,Class<?>> moreResultClasses) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic <E> E get(SqlSession session, Class<E> resultClass, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException
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 executionSqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingprivate <E> E get(SqlQuery query, SqlMappingResult mappingResult, Class<E> resultClass, SqlControl sqlControl)
query - querymappingResult - mappingResultresultClass - resultClasssqlControl - sqlCOntrolpublic int update(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
update(SqlSession, Object, Object, int) .public int update(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
update(SqlSession, Object, Object, int) .public int update(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic int update(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException, SqlValidationException
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 executionSqlProcessorException - 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 successfullprivate Integer update(SqlQuery query, SqlProcessResult processResult)
query - querypublic int delete(SqlSession session, Object dynamicInputValues) throws SqlProcessorException, SqlRuntimeException
delete(SqlSession, Object, Object, int) .public int delete(SqlSession session, Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
delete(SqlSession, Object, Object, int) .public int delete(SqlSession session, Object dynamicInputValues, Object staticInputValues, int maxTimeout) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic int delete(SqlSession session, Object dynamicInputValues, SqlControl sqlControl) throws SqlProcessorException, SqlRuntimeException
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 executionSqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingprivate Integer delete(SqlQuery query, SqlProcessResult processResult)
query - querypublic String getInsertSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .public String getGetSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.public String getUpdateSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .public String getDeleteSql(Object dynamicInputValues, Object staticInputValues) throws SqlProcessorException, SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .public String getSql(Object dynamicInputValues, Object staticInputValues, SqlMetaStatement.Type statementType) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic String getSql(Object dynamicInputValues, SqlControl sqlControl, SqlMetaStatement.Type statementType) throws SqlProcessorException, SqlRuntimeException
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.SqlProcessorException - in the case of any problem with ORM or JDBC stackSqlRuntimeException - in the case of any problem with the input/output values handlingpublic String getName()
public SqlMonitor getMonitor()
Copyright © 2016. All rights reserved.