|
||||||||||
| 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 queries.properties there's the next definition:
CRUD_UPDATE_PERSON= \
update PERSON \
{= set name = :name} \
{= where {& id = :id^long^notnull}}
In the case of SQL Processor initialization
SqlPropertiesLoader loader = new SqlPropertiesLoader("queries.properties", this.getClass());
SqlEngineLoader sqlLoader = new SqlEngineLoader(loader.getProperties());
SqlCrudEngine sqlEngine = sqlLoader.getCrudEngine("UPDATE_PERSON");
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 Reference Guide or tutorials.
| Field Summary |
|---|
| Fields inherited from class org.sqlproc.engine.SqlEngine |
|---|
features, logger, mapping, monitor, name, statement |
| Constructor Summary | |
|---|---|
SqlCrudEngine(java.lang.String name,
SqlMetaStatement statement)
Creates a new instance of SqlCrudEngine from one META SQL statement instance. |
|
SqlCrudEngine(java.lang.String name,
SqlMetaStatement statement,
SqlMonitor monitor,
java.util.Map<java.lang.String,java.lang.Object> features)
Creates a new instance of SqlCrudEngine from one META SQL statement instance. |
|
SqlCrudEngine(java.lang.String name,
java.lang.String statement)
Creates a new instance of SqlCrudEngine from one META SQL statement string. |
|
SqlCrudEngine(java.lang.String name,
java.lang.String statement,
SqlMonitor monitor,
java.util.Map<java.lang.String,java.lang.Object> features)
Creates a new instance of SqlCrudEngine from one META SQL statement string. |
|
| Method Summary | ||
|---|---|---|
|
delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
Runs a META SQL delete statement to delete a database row. |
|
|
delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Runs a META SQL delete statement to delete a database row. |
|
|
delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
Runs a META SQL delete statement to delete a database row. |
|
|
get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues)
Runs a META SQL query to obtain a unique database row. |
|
|
get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Runs a META SQL query to obtain a unique database row. |
|
|
get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
Runs a META SQL query to obtain a unique database row. |
|
java.lang.String |
getDeleteSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Returns the delete statement derived from the META SQL statement. |
|
java.lang.String |
getGetSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Returns the query select statement derived from the META SQL statement. |
|
java.lang.String |
getInsertSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Returns the insert statement derived from the META SQL statement. |
|
SqlMonitor |
getMonitor()
Returns the SQL Monitor instance for the runtime statistics gathering. |
|
java.lang.String |
getName()
Returns the name of this META SQL, which uniquely identifies the instance. |
|
java.lang.String |
getSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
SqlMetaStatement.Type statementType)
Because SQL Processor is Data Driven Query engine, every input parameters can produce in fact different SQL statement command. |
|
java.lang.String |
getUpdateSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Returns the update statement derived from the META SQL statement. |
|
|
insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
Runs a META SQL insert statement to persist a database row. |
|
|
insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Runs a META SQL insert statement to persist a database row. |
|
|
insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
Runs a META SQL insert statement to persist a database row. |
|
|
update(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
Runs a META SQL update statement to persist a database row. |
|
|
update(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
Runs a META SQL update statement to persist a database row. |
|
|
update(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
Runs a META SQL update statement to persist a database row. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SqlCrudEngine(java.lang.String name,
java.lang.String statement)
throws SqlEngineException
name - the name if this SQL Engine instancestatement - the META SQL CRUD statement, extension of ANSI SQL
SqlEngineException - mainly in the case the provided statements are not compliant with the ANTLR grammar
public SqlCrudEngine(java.lang.String name,
java.lang.String statement,
SqlMonitor monitor,
java.util.Map<java.lang.String,java.lang.Object> features)
throws SqlEngineException
name - the name if this SQL Engine instancestatement - the META SQL CRUD statement, extension of ANSI SQLmonitor - the SQL Monitor for the runtime statistics gatheringfeatures - the optional SQL Processor features
SqlEngineException - mainly in the case the provided statements are not compliant with the ANTLR grammar
public SqlCrudEngine(java.lang.String name,
SqlMetaStatement statement)
name - the name if this SQL Engine instancestatement - the precompiled META SQL CRUD statement, extension of ANSI SQL
public SqlCrudEngine(java.lang.String name,
SqlMetaStatement statement,
SqlMonitor monitor,
java.util.Map<java.lang.String,java.lang.Object> features)
name - the name if this SQL Engine instancestatement - the precompiled META SQL statement, extension of ANSI SQLmonitor - the SQL Monitor for the runtime statistics gatheringfeatures - the optional SQL Processor features| Method Detail |
|---|
public <E> int insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
throws org.hibernate.HibernateException
insert(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
insert(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int insert(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
throws org.hibernate.HibernateException
session - Hibernate session, first level cache and the SQL query execution contextdynamicInputValues - The object used for the SQL statement dynamic parameters. 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 substituted into the SQL prepared statement are picked up using the reflection API.staticInputValues - The object used for the SQL statement static parameters. 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 the 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.
org.hibernate.HibernateException
public <E> E get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues)
throws org.hibernate.HibernateException
get(Session, Class, Object, Object, int) .
org.hibernate.HibernateException
public <E> E get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
get(Session, Class, Object, Object, int) .
org.hibernate.HibernateException
public <E> E get(org.hibernate.Session session,
java.lang.Class<E> resultClass,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
throws org.hibernate.HibernateException
session - Hibernate session, first level cache and the SQL query execution contextresultClass - 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 instance of this class are created on the fly in
the query execution using the reflection API.dynamicInputValues - The object used for the SQL statement dynamic parameters. 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 substituted into the SQL prepared statement are picked up using the reflection API.staticInputValues - The object used for the SQL statement static parameters. 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 the 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.
org.hibernate.HibernateException
public <E> int update(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
throws org.hibernate.HibernateException
update(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int update(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
update(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int update(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
throws org.hibernate.HibernateException
session - Hibernate session, first level cache and the SQL query execution contextdynamicInputValues - The object used for the SQL statement dynamic parameters. 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 substituted into the SQL prepared statement are picked up using the reflection API.staticInputValues - The object used for the SQL statement static parameters. 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 the 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.
org.hibernate.HibernateException
public <E> int delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues)
throws org.hibernate.HibernateException
delete(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
delete(Session, Object, Object, int)
.
org.hibernate.HibernateException
public <E> int delete(org.hibernate.Session session,
java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
int maxTimeout)
throws org.hibernate.HibernateException
session - Hibernate session, first level cache and the SQL query execution contextdynamicInputValues - The object used for the SQL statement dynamic parameters. 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 substituted into the SQL prepared statement are picked up using the reflection API.staticInputValues - The object used for the SQL statement static parameters. 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 the 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.
org.hibernate.HibernateException
public java.lang.String getInsertSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
org.hibernate.HibernateException
public java.lang.String getGetSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type)
.
org.hibernate.HibernateException
public java.lang.String getUpdateSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
org.hibernate.HibernateException
public java.lang.String getDeleteSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues)
throws org.hibernate.HibernateException
getSql(Object, Object, org.sqlproc.engine.impl.SqlMetaStatement.Type) .
org.hibernate.HibernateException
public java.lang.String getSql(java.lang.Object dynamicInputValues,
java.lang.Object staticInputValues,
SqlMetaStatement.Type statementType)
throws org.hibernate.HibernateException
dynamicInputValues - The object used for the SQL statement dynamic parameters. 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 substituted into the SQL prepared statement are picked up using the reflection API.staticInputValues - The object used for the SQL statement static parameters. 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 the end user to
prevent SQL injection threat!statementType - The type of the statement under consideration. It can be CREATE, RETRIEVE, UPDATE or DELETE.
org.hibernate.HibernateExceptionpublic java.lang.String getName()
public SqlMonitor getMonitor()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||