public class SQLQuery extends CloneableDataObject implements SemanticQuery
Title: SQL Object Mediation
Description: Holds resolved SQL Query
and list of query parameters.
An SQL Query
object encapsulates a prepared
SQL query with it's associate,
dynamically substitutable parameters. Query objects are structured-syntax entities. They are created by
resolving an arbitrary SQL statement into an abstract syntax tree and generating a Structured
Data Object
from that tree. SQL Query objects use a special abstract variable substitution syntax,
the same one used by Event Trigger
and the SLANG
interpreter to pre-process
the SQL statements, resolve defaults and specify type checking.
Query objects are managed by SQLQueryFactory
. The factory allows developers to create instances
of the object from an SQL statement, persist the query entities or re-generate the original query from
the object's sytnax tree.
Query objects may be encapsulated in a Data Event
and raised as SQL Events within the
Service Event Fabric
or transmitted between applications using a Messaging System such
as JMS or event HTTP. They may be mapped to/from Row Set objects, assembled into
batch scripts or used to intercept and parse SQL statements, allowing users to analyze the affected
table structures. Queries may be used to express standard SQL statements, stored procedures or DML
statements. The SQLQueryFactory
further provides methods for automatically generating queries
for SELECT
, INSERT
, UPDATE
, DELETE
and stored procedure
invocation.
Copyright: Copyright (c) 2009
Company: StreamScape Technologies
SQLQueryBatch
,
SQLQueryParameter
,
SQLQueryMapper
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
SQL_QUERY_OBJECTS_NAMESPACE |
DEFAULT_SERIAL_VERSION_ID
Constructor and Description |
---|
SQLQuery()
A default constructor.
|
SQLQuery(java.lang.String sqlScript,
int queryType)
Constructs objects based on given sql script and type
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Deep copy
|
java.lang.String |
getDescription()
Returns the quiery's description.
|
java.lang.String |
getName()
Returns the name of the query.
|
SQLQueryParameter |
getParameter(int ordinal)
Return a parameter by it's ordinal value.
|
SQLQueryParameter |
getParameter(java.lang.String name)
Return parameter by name.
|
java.util.Iterator |
getParameterIterator()
Returns an
Iterator of SQLQueryParameter
objects. |
SQLQueryParameterList |
getParameters()
Returns a query parameter list object which may be manipulated directly.
|
int |
getQueryType()
Returns query type which can be one of:
SQLQueryType.SELECT
SQLQueryType.UPDATE
SQLQueryType.INSERT
SQLQueryType.DELETE
SQLQueryType.CALL
SQLQueryType.CALL_WITH_RETURN
|
java.lang.String |
getSqlScript()
Returns the sql script this object is based on.
|
boolean |
isCallable()
Checks whether this object contains sql script to call stored procedure
|
void |
setDescription(java.lang.String description)
Sets the description of the query.
|
void |
setName(java.lang.String name)
Sets the name for this query.
|
void |
setParameter(int ordinal,
java.lang.String value)
Sets value to the parameter by its ordinal and accepts a string.
|
void |
setParameter(java.lang.String name,
java.lang.Object value)
Sets value to the parameter by its name and accepts an object.
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Sets the value of a parameter by it's name passing in a string.
|
void |
setQueryType(int sqlQueryType)
Sets the SQL Query type which can be one of:
SQLQueryType.SELECT
SQLQueryType.UPDATE
SQLQueryType.INSERT
SQLQueryType.DELETE
SQLQueryType.CALL
SQLQueryType.CALL_WITH_RETURN
|
getSerialVersionUID
public SQLQuery()
public SQLQuery(java.lang.String sqlScript, int queryType)
sqlScript
- sql scriptqueryType
- query typepublic SQLQueryParameter getParameter(java.lang.String name) throws SQLQueryValidationException
name
- StringSQLQueryValidationException
public SQLQueryParameter getParameter(int ordinal) throws SQLQueryValidationException
ordinal
- intSQLQueryValidationException
public java.util.Iterator getParameterIterator()
Iterator
of SQLQueryParameter
objects. Such objects may be manipulated independently.public void setParameter(java.lang.String name, java.lang.String value) throws SQLQueryValidationException
prepare
. Finally, during the query's execution
a parameter will be applied using the data type defined in the
query object. Hence the query object acts as a pre-processor
for potentially identifying conversion errors.name
- Stringvalue
- StringSQLQueryValidationException
public void setParameter(java.lang.String name, java.lang.Object value) throws SQLQueryValidationException
SQLTypeToken
mapping.name
- parameter namevalue
- parameter value given by objectSQLQueryValidationException
- if parameter is declared as OUT parameterpublic void setParameter(int ordinal, java.lang.String value) throws SQLQueryValidationException
ordinal
- parameter ordinalvalue
- parameter value given by stringSQLQueryValidationException
- if parameter is declared as OUT parameterpublic SQLQueryParameterList getParameters()
public void setName(java.lang.String name)
name
- Stringpublic java.lang.String getName()
getName
in interface SemanticQuery
public void setDescription(java.lang.String description)
description
- Stringpublic java.lang.String getDescription()
getDescription
in interface SemanticQuery
public java.lang.String getSqlScript()
public boolean isCallable()
public void setQueryType(int sqlQueryType)
SQLQueryType.SELECT
SQLQueryType.UPDATE
SQLQueryType.INSERT
SQLQueryType.DELETE
SQLQueryType.CALL
SQLQueryType.CALL_WITH_RETURN
public int getQueryType()
SQLQueryType.SELECT
SQLQueryType.UPDATE
SQLQueryType.INSERT
SQLQueryType.DELETE
SQLQueryType.CALL
SQLQueryType.CALL_WITH_RETURN
public java.lang.Object clone()
clone
in interface CloneableObject
clone
in class CloneableDataObject
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.