|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sqlproc.engine.SqlEngine
org.sqlproc.engine.SqlCrudEngine
public class SqlCrudEngine
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 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.
| Field Summary |
|---|
| Fields inherited from class org.sqlproc.engine.SqlEngine |
|---|
features, logger, mapping, monitor, name, pluginFactory, statement, typeFactory |
| Constructor Summary | |
|---|---|
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,
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. |
|
| Method Summary | ||
|---|---|---|
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. |
|
|
get(SqlSession session,
Class<E> resultClass,
Object dynamicInputValues)
Runs the META SQL query to obtain a unique database row. |
|
|
get(SqlSession session,
Class<E> resultClass,
Object dynamicInputValues,
Object staticInputValues)
Runs the META SQL query to obtain a unique database row. |
|
|
get(SqlSession session,
Class<E> resultClass,
Object dynamicInputValues,
Object staticInputValues,
int maxTimeout)
Runs the META SQL query to obtain a unique database row. |
|
|
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. |
|
|
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. |
|
|
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 |
getUpdateSql(Object dynamicInputValues,
Object staticInputValues)
Returns the update statement derived from the META SQL statement. |
|
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. |
|
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. |
|
| Methods inherited from class org.sqlproc.engine.SqlEngine |
|---|
getFirstResult, getMaxResults, getMaxTimeout, getMoreResultClasses, getOrder, getStaticInputValues, setFeature, unsetFeature |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public 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 plugins
SqlEngineException - in the case the provided statements are not compliant with the ANTLR grammar
public 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 plugins
SqlEngineException - in the case the provided statements are not compliant with the ANTLR grammar
public 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 plugins
public 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 plugins
public 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 plugins| Method Detail |
|---|
public int insert(SqlSession session,
Object dynamicInputValues)
throws SqlProcessorException,
SqlRuntimeException
insert(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
public int insert(SqlSession session,
Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
insert(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
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 stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public int insert(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 execution
SqlProcessorException - in the case of any problem with ORM or JDBC stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public <E> E get(SqlSession session,
Class<E> resultClass,
Object dynamicInputValues)
throws SqlProcessorException,
SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .
SqlProcessorException
SqlRuntimeException
public <E> E get(SqlSession session,
Class<E> resultClass,
Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
get(SqlSession, Class, Object, Object, int, Map) .
SqlProcessorException
SqlRuntimeException
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) .
SqlProcessorException
SqlRuntimeException
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) .
SqlProcessorException
SqlRuntimeException
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 stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public <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 execution
SqlProcessorException - in the case of any problem with ORM or JDBC stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public int update(SqlSession session,
Object dynamicInputValues)
throws SqlProcessorException,
SqlRuntimeException
update(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
public int update(SqlSession session,
Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
update(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
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 stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public int update(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 execution
SqlProcessorException - in the case of any problem with ORM or JDBC stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public int delete(SqlSession session,
Object dynamicInputValues)
throws SqlProcessorException,
SqlRuntimeException
delete(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
public int delete(SqlSession session,
Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
delete(SqlSession, Object, Object, int) .
SqlProcessorException
SqlRuntimeException
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 stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public 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 execution
SqlProcessorException - in the case of any problem with ORM or JDBC stack
SqlRuntimeException - in the case of any problem with the input/output values handling
public String getInsertSql(Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
SqlProcessorException
SqlRuntimeException
public String getGetSql(Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
SqlProcessorException
SqlRuntimeException
public String getUpdateSql(Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
SqlProcessorException
SqlRuntimeException
public String getDeleteSql(Object dynamicInputValues,
Object staticInputValues)
throws SqlProcessorException,
SqlRuntimeException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
SqlProcessorException
SqlRuntimeException
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 stack
SqlRuntimeException - in the case of any problem with the input/output values handlingpublic String getName()
public SqlMonitor getMonitor()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||