org.sqlproc.engine
Interface SqlFeature


public interface SqlFeature

Optional features, which can be activated in the process of SQL Processor initialization. The internal class SqlContext implements this interface.

The features can be incorporated into queries.properties file in the form of SET_... properties.

For example the SQL Processor supports the special searching feature based on text fragments. Lets have a table PERSON with two columns - ID and NAME.
In queries.properties there's the next definition:

 SET_LIKE_STRING=like
 SET_WILDCARD_CHARACTER=%
 SET_SURROUND_QUERY_LIKE=true
 SET_SURROUND_QUERY_MIN_LEN=2
 
 QRY_LIKE_PEOPLE= \
   select p.ID @id, p.NAME @name \
   from PERSON p \
   {= where \
    {& id=:id} \
    {& UPPER(name) like :+name} \
   } \
   {#1 order by ID} \
   {#2 order by NAME}
 

The special searching capability is activated with the next statement in queries.properties:

 SET_SURROUND_QUERY_LIKE = true
 
In this case every query with the like keyword is identified and a dynamic input parameter, which belongs to this query condition, is handled in a special way. The value for this parameter is surrounded with wildcard character %. This character is defined in queries.properties with the key SET_WILDCARD_CHARACTER. In the runtime to activate this feature, the parameter value has to have the minimal length = 2. This minimal length is defined in queries.properties with the key SET_SURROUND_QUERY_MIN_LEN. In the case of SQL Processor initialization
 SqlPropertiesLoader loader = new SqlPropertiesLoader("queries.properties", this.getClass());
 SqlEngineLoader sqlLoader = new SqlEngineLoader(loader.getProperties());
 SqlEngine sqlEngine = sqlLoader.getSqlEngine("LIKE_PEOPLE");
 
there's created an instance of SqlEngine with the name LIKE_PEOPLE.

Next there's an instance person of the class Person with the value an for the attribute name. The invocation

 List<Person> list = sqlEngine.query(session, Person.class, person, SqlOrder.getDescOrder(2));
 
produces the next SQL execution
 select p.ID id, p.NAME name from PERSON p where UPPER(name) like ? order by NAME DESC
 
In the result list there are all table rows with name, which contains the text fragment an.

For more info please see the Reference Guide or tutorials.

Author:
Vladimir Hudec

Field Summary
static java.lang.String DEFAULT_LIKE_STRING
          This is the default value for the key SET_LIKE_STRING.
static java.lang.String[] DEFAULT_METHODS_ENUM_IN
          This is the default value for the key SET_METHODS_ENUM_IN.
static java.lang.String[] DEFAULT_METHODS_ENUM_OUT
          This is the default value for the key SET_METHODS_ENUM_OUT.
static java.lang.Integer DEFAULT_SURROUND_QUERY_MIN_LEN
          This is the default value for the key SET_SURROUND_QUERY_MIN_LEN.
static java.lang.String DEFAULT_WILDCARD_CHARACTER
          This is the default value for the key SET_WILDCARD_CHARACTER .
static java.lang.String ID
          ID is the key for the identity columns.
static java.lang.String IGNORE_INPROPER_IN
          IGNORE_INPROPER_IN is the key for special handling of input/output values.
static java.lang.String IGNORE_INPROPER_OUT
          IGNORE_INPROPER_OUT is the key for special handling of input/output values.
static java.lang.String LIKE_STRING
          SET_LIKE_STRING is the key for the like sql command.
static java.lang.String METHODS_ENUM_IN
          SET_METHODS_ENUM_IN lists the methods used in the translation from a Java type to a JDBC datatype for enumerations.
static java.lang.String METHODS_ENUM_OUT
          SET_METHODS_ENUM_OUT lists the methods used in the translation from a JDBC datatype to a Java type for enumerations.
static java.lang.String SURROUND_QUERY_LIKE
          SET_SURROUND_QUERY_LIKE is the key for the special SQL Processor behavior.
static java.lang.String SURROUND_QUERY_MIN_LEN
          SET_SURROUND_QUERY_MIN_LEN is the minimal length of the string input values for the SQL like command to switch on the SQL Processor special behavior described above in the runtime.
static java.lang.String WILDCARD_CHARACTER
          SET_WILDCARD_CHARACTER is the key for the wildcard character for SQL like command in the properties.
 

Field Detail

WILDCARD_CHARACTER

static final java.lang.String WILDCARD_CHARACTER
SET_WILDCARD_CHARACTER is the key for the wildcard character for SQL like command in the properties.

See Also:
Constant Field Values

DEFAULT_WILDCARD_CHARACTER

static final java.lang.String DEFAULT_WILDCARD_CHARACTER
This is the default value for the key SET_WILDCARD_CHARACTER .

See Also:
Constant Field Values

SURROUND_QUERY_LIKE

static final java.lang.String SURROUND_QUERY_LIKE
SET_SURROUND_QUERY_LIKE is the key for the special SQL Processor behavior. In the case the value of this property is true, the SQL Processor puts wildcard character as a prefix and postfix for all string values in the SQL select commands like. These string values should have to have the minimal length greater or equal to SET_SURROUND_QUERY_MIN_LEN.

See Also:
Constant Field Values

SURROUND_QUERY_MIN_LEN

static final java.lang.String SURROUND_QUERY_MIN_LEN
SET_SURROUND_QUERY_MIN_LEN is the minimal length of the string input values for the SQL like command to switch on the SQL Processor special behavior described above in the runtime.

See Also:
Constant Field Values

DEFAULT_SURROUND_QUERY_MIN_LEN

static final java.lang.Integer DEFAULT_SURROUND_QUERY_MIN_LEN
This is the default value for the key SET_SURROUND_QUERY_MIN_LEN.


LIKE_STRING

static final java.lang.String LIKE_STRING
SET_LIKE_STRING is the key for the like sql command. For example for the Informix database it can be matches.

See Also:
Constant Field Values

DEFAULT_LIKE_STRING

static final java.lang.String DEFAULT_LIKE_STRING
This is the default value for the key SET_LIKE_STRING.

See Also:
Constant Field Values

METHODS_ENUM_IN

static final java.lang.String METHODS_ENUM_IN
SET_METHODS_ENUM_IN lists the methods used in the translation from a Java type to a JDBC datatype for enumerations.

See Also:
Constant Field Values

DEFAULT_METHODS_ENUM_IN

static final java.lang.String[] DEFAULT_METHODS_ENUM_IN
This is the default value for the key SET_METHODS_ENUM_IN.


METHODS_ENUM_OUT

static final java.lang.String METHODS_ENUM_OUT
SET_METHODS_ENUM_OUT lists the methods used in the translation from a JDBC datatype to a Java type for enumerations.

See Also:
Constant Field Values

DEFAULT_METHODS_ENUM_OUT

static final java.lang.String[] DEFAULT_METHODS_ENUM_OUT
This is the default value for the key SET_METHODS_ENUM_OUT.


ID

static final java.lang.String ID
ID is the key for the identity columns. In the case it'd defined, all columns with this name is implicitly treated as an identifier.

See Also:
Constant Field Values

IGNORE_INPROPER_IN

static final java.lang.String IGNORE_INPROPER_IN
IGNORE_INPROPER_IN is the key for special handling of input/output values. In the case it'd defined as true, in the case of any problems with input values the SqlRuntimeException is not thrown, only the error is logged.

See Also:
Constant Field Values

IGNORE_INPROPER_OUT

static final java.lang.String IGNORE_INPROPER_OUT
IGNORE_INPROPER_OUT is the key for special handling of input/output values. In the case it'd defined as true, in the case of any problems with output values the SqlRuntimeException is not thrown, only the error is logged.

See Also:
Constant Field Values


Copyright © 2011. All Rights Reserved.