Enum SqlFeature
- java.lang.Object
-
- java.lang.Enum<SqlFeature>
-
- org.sqlproc.engine.SqlFeature
-
- All Implemented Interfaces:
Serializable
,Comparable<SqlFeature>
public enum SqlFeature extends Enum<SqlFeature>
The optional features are used to alter the behavior of the SQL Processor. They can be activated in the process of SQL Processor initialization.The features can be incorporated into the meta statements file in the form of
name(OPT)=...;
.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 the meta statements file statements.qry there's the next definition:LIKE_STRING(OPT)=like; WILDCARD_CHARACTER(OPT)=%; SURROUND_QUERY_LIKE_FULL(BOPT)=true; SURROUND_QUERY_MIN_LEN(IOPT)=2; LIKE_PEOPLE(QRY)= 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 key
SURROUND_QUERY_LIKE(BOPT)=true
. In this case every query with the like keyword (defined with the keyLIKE_STRING
) is identified and any dynamic input value, which belongs to this query condition, is handled in a special way. The value for this input value is surrounded with wild-card character%
. This character is defined with the keyWILDCARD_CHARACTER
. In the runtime to activate this feature, the input value has to have the minimal length = 2. This minimal length is defined with the keySURROUND_QUERY_MIN_LEN
. In the case of SQL Processor initializationJdbcEngineFactory sqlFactory = new JdbcEngineFactory(); sqlFactory.setMetaFilesNames("statements.qry"); // the meta statements file SqlEngine sqlEngine = sqlFactory.getSqlEngine("LIKE_PEOPLE"); // 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 SqlEngine with the nameLIKE_PEOPLE
.Next there's an instance person of the class Person with the value
an
for the attribute name. The invocationPerson person = new Person(); person.setName("jan"); List<Person> list = sqlEngine.query(session, Person.class, person, SqlOrder.getDescOrder(2));
produces the next SQL executionselect 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 fragmentjan
.For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CASSANDRA
The filter for Cassandra devoted optional features.COLLECTIONS_ARE_STANDARD_TYPES
COLLECTIONS_ARE_STANDARD_TYPES
is indicator that Collections should be handled as standard types.DB2
The filter for DB2 Server devoted optional features.EMPTY_FOR_NULL
EMPTY_FOR_NULL
is indicator that the NULL values are always empty.EMPTY_USE_METHOD_IS_NULL
EMPTY_USE_METHOD_IS_NULL
is indicator that the non-emptiness depends the special isNull method.FILTER
FILTER
is the main filter in SqlProcessorLoader, if any.H2
The filter for H2 devoted optional features.HSQLDB
The filter for HSQLDB devoted optional features.ID
ID
is the key for the identity columns.IDGEN
IDGEN
is the key for the SQL query pattern used to obtain the value of identities or sequences.IDSEL
IDSEL
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IDSEL_Integer
IDSEL_Integer
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IDSEL_Long
IDSEL_Long
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IGNORE_INPROPER_IN
IGNORE_INPROPER_IN
is the key for special handling of input/output values.IGNORE_INPROPER_OUT
IGNORE_INPROPER_OUT
is the key for special handling of input/output values.INFORMIX
The filter for Informix devoted optional features.JDBC
JDBC
is the key for the raw JDBC stack usage.LIKE_STRING
LIKE_STRING
is the key for the SQL commandlike
.LIMIT_FROM_TO
LIMIT_FROM_TO
is the key for the SQL query pattern used to limit the query results.LIMIT_FROM_TO_ORDERED
LIMIT_FROM_TO_ORDERED
is the key for the SQL query pattern used to limit the query results in the case the query output is sorted.LIMIT_TO
LIMIT_TO
is the key for the SQL query pattern used to limit the query results.LIMIT_TO_ORDERED
LIMIT_TO_ORDERED
is the key for the SQL query pattern used to limit the query results in the case the query output is sorted.LOG_SQL_COMMAND_FOR_EXCEPTION
LOG_SQL_COMMAND_FOR_EXCEPTION
is the indicator that in the case of an SQLException the related SQL command should be logged.METHODS_ENUM_IN
METHODS_ENUM_IN
lists the methods used in the translation from a Java type to a JDBC datatype for enumerations based input values.METHODS_ENUM_OUT
METHODS_ENUM_OUT
lists the methods used in the translation from a JDBC datatype to a Java type for enumerations based output values.MSSQL
The filter for MS SQL Server devoted optional features.MYSQL
The filter for MySQL devoted optional features.OPERATOR_ATTRIBUTE
OPERATOR_ATTRIBUTE
is the operator atribute name suffix.OPERATOR_ATTRIBUTE_IN_MAP
OPERATOR_ATTRIBUTE_IN_MAP
is the map name of the operators name suffix.ORACLE
The filter for Oracle devoted optional features.POSTGRESQL
The filter for PostgreSQL devoted optional features.REPLACE_LIKE_CHARS
REPLACE_LIKE_CHARS
is the key for the special SQL Processor behavior related to the SQL commandlike
.REPLACE_LIKE_STRING
REPLACE_LIKE_STRING
is the key for the special SQL Processor behavior related to the SQL commandlike
.SEQ
SEQ
is the key for the SQL query pattern used for the sequences.SEQ_NAME
SEQ_NAME
is the key for the sequence name.SKIP_ALIASES_IN_SQL_COMMAND
SKIP_ALIASES_IN_SQL_COMMAND
is indicator that column aliases are not included in generated SQL command.SURROUND_QUERY_LIKE_FULL
SURROUND_QUERY_LIKE
is the key for the special SQL Processor behavior.SURROUND_QUERY_LIKE_PARTIAL
SURROUND_QUERY_LIKE_PARTIAL
is the key for the special SQL Processor behavior.SURROUND_QUERY_MIN_LEN
SURROUND_QUERY_MIN_LEN
is the minimal length of the string input values for the SQLlike
command to switch on the SQL Processor special behavior described above in the runtime.VERSION_COLUMN
VERSION_COLUMN
is the key for the version column name.WILDCARD_CHARACTER
WILDCARD_CHARACTER
is the key for the wildcard character for the SQLlike
command.
-
Constructor Summary
Constructors Modifier Constructor Description private
SqlFeature()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SqlFeature
valueOf(String name)
Returns the enum constant of this type with the specified name.static SqlFeature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ORACLE
public static final SqlFeature ORACLE
The filter for Oracle devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
HSQLDB
public static final SqlFeature HSQLDB
The filter for HSQLDB devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
MYSQL
public static final SqlFeature MYSQL
The filter for MySQL devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
POSTGRESQL
public static final SqlFeature POSTGRESQL
The filter for PostgreSQL devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
INFORMIX
public static final SqlFeature INFORMIX
The filter for Informix devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
MSSQL
public static final SqlFeature MSSQL
The filter for MS SQL Server devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
DB2
public static final SqlFeature DB2
The filter for DB2 Server devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
H2
public static final SqlFeature H2
The filter for H2 devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
CASSANDRA
public static final SqlFeature CASSANDRA
The filter for Cassandra devoted optional features. It can be used for the construction ofSqlProcessorLoader
.
-
WILDCARD_CHARACTER
public static final SqlFeature WILDCARD_CHARACTER
WILDCARD_CHARACTER
is the key for the wildcard character for the SQLlike
command.
-
SURROUND_QUERY_LIKE_FULL
public static final SqlFeature SURROUND_QUERY_LIKE_FULL
SURROUND_QUERY_LIKE
is the key for the special SQL Processor behavior. In the case the value of this property istrue
, the SQL Processor sets the wildcard character as a prefix and postfix for all string values related to the SQL commandlike
. These string values should have to have the minimal length greater or equal toSURROUND_QUERY_MIN_LEN
. The default value related to this key isfalse
.
-
SURROUND_QUERY_LIKE_PARTIAL
public static final SqlFeature SURROUND_QUERY_LIKE_PARTIAL
SURROUND_QUERY_LIKE_PARTIAL
is the key for the special SQL Processor behavior. In the case the value of this property istrue
, the SQL Processor sets the wildcard character as a postfix for all string values related to the SQL commandlike
. These string values should have to have the minimal length greater or equal toSURROUND_QUERY_MIN_LEN
. The default value related to this key isfalse
.
-
SURROUND_QUERY_MIN_LEN
public static final SqlFeature SURROUND_QUERY_MIN_LEN
SURROUND_QUERY_MIN_LEN
is the minimal length of the string input values for the SQLlike
command to switch on the SQL Processor special behavior described above in the runtime.
-
LIKE_STRING
public static final SqlFeature LIKE_STRING
LIKE_STRING
is the key for the SQL commandlike
. For example for the Informix database it can bematches
.
-
REPLACE_LIKE_STRING
public static final SqlFeature REPLACE_LIKE_STRING
REPLACE_LIKE_STRING
is the key for the special SQL Processor behavior related to the SQL commandlike
. The supplied value is going to be used as the final LIKE_STRING.
-
REPLACE_LIKE_CHARS
public static final SqlFeature REPLACE_LIKE_CHARS
REPLACE_LIKE_CHARS
is the key for the special SQL Processor behavior related to the SQL commandlike
. The feature pattern is['c1':'r1', 'c2':'r2', ...]
, wherec1,c2,...
is a set of characters to be replaced with the charactersr1,r2,...
. For example to use the wildcard characters*
and?
instead of%
_
, use['*':'%', '?':'_']
.
-
METHODS_ENUM_IN
public static final SqlFeature METHODS_ENUM_IN
METHODS_ENUM_IN
lists the methods used in the translation from a Java type to a JDBC datatype for enumerations based input values.
-
METHODS_ENUM_OUT
public static final SqlFeature METHODS_ENUM_OUT
METHODS_ENUM_OUT
lists the methods used in the translation from a JDBC datatype to a Java type for enumerations based output values.
-
ID
public static final SqlFeature ID
ID
is the key for the identity columns. In the case it's values is defined, all columns with this name are implicitly treated as an identifier.
-
IGNORE_INPROPER_IN
public static final SqlFeature IGNORE_INPROPER_IN
IGNORE_INPROPER_IN
is the key for special handling of input/output values. In the case it's value is defined as true, in the case of any problems with input values the SqlRuntimeException is not thrown, only the related error is logged.
-
IGNORE_INPROPER_OUT
public static final SqlFeature IGNORE_INPROPER_OUT
IGNORE_INPROPER_OUT
is the key for special handling of input/output values. In the case it's value is defined as true, in the case of any problems with output values the SqlRuntimeException is not thrown, only the related error is logged.
-
JDBC
public static final SqlFeature JDBC
JDBC
is the key for the raw JDBC stack usage. In this SQL Processor version the next stacks can be used:- raw JDBC
- Hibernate
- Spring DAO
false
.
-
LIMIT_FROM_TO
public static final SqlFeature LIMIT_FROM_TO
LIMIT_FROM_TO
is the key for the SQL query pattern used to limit the query results. This pattern has to be combined with the original SQL query, the limit and the offset in the next way:- $S is the full original query
- $s is the original query without the token
select
- $F is 1-based from rowid (=offset)
- $f is 0-based from rowid (offset)
- $M is the max number of returned rows
- $m is the max rowid of returned rows
-
LIMIT_FROM_TO_ORDERED
public static final SqlFeature LIMIT_FROM_TO_ORDERED
LIMIT_FROM_TO_ORDERED
is the key for the SQL query pattern used to limit the query results in the case the query output is sorted. Right now it's used only for HSQLDB.
-
LIMIT_TO
public static final SqlFeature LIMIT_TO
LIMIT_TO
is the key for the SQL query pattern used to limit the query results. This pattern has to be combined with the original SQL query and the limit in the next way:- $S is the full original query
- $s is the original query without the token
select
- $F is 1-based from rowid (=offset)
- $f is 0-based from rowid (offset)
-
LIMIT_TO_ORDERED
public static final SqlFeature LIMIT_TO_ORDERED
LIMIT_TO_ORDERED
is the key for the SQL query pattern used to limit the query results in the case the query output is sorted. Right now it's used only for HSQLDB.
-
SEQ
public static final SqlFeature SEQ
SEQ
is the key for the SQL query pattern used for the sequences. This pattern can be combined with the sequence name used in the META SQL query in the next way:- $n is the name of the sequence from the META SQL query
-
SEQ_NAME
public static final SqlFeature SEQ_NAME
SEQ_NAME
is the key for the sequence name.
-
IDSEL
public static final SqlFeature IDSEL
IDSEL
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.
-
IDSEL_Long
public static final SqlFeature IDSEL_Long
IDSEL_Long
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.
-
IDSEL_Integer
public static final SqlFeature IDSEL_Integer
IDSEL_Integer
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.
-
IDGEN
public static final SqlFeature IDGEN
IDGEN
is the key for the SQL query pattern used to obtain the value of identities or sequences.
-
VERSION_COLUMN
public static final SqlFeature VERSION_COLUMN
VERSION_COLUMN
is the key for the version column name.
-
EMPTY_FOR_NULL
public static final SqlFeature EMPTY_FOR_NULL
EMPTY_FOR_NULL
is indicator that the NULL values are always empty. It has meaning for the UPDATE statements, where the standard handling is to treat any values as not empty.
-
EMPTY_USE_METHOD_IS_NULL
public static final SqlFeature EMPTY_USE_METHOD_IS_NULL
EMPTY_USE_METHOD_IS_NULL
is indicator that the non-emptiness depends the special isNull method. It has meaning for the UPDATE statements, where the standard handling is to treat any values as not empty.
-
OPERATOR_ATTRIBUTE
public static final SqlFeature OPERATOR_ATTRIBUTE
OPERATOR_ATTRIBUTE
is the operator atribute name suffix.
-
OPERATOR_ATTRIBUTE_IN_MAP
public static final SqlFeature OPERATOR_ATTRIBUTE_IN_MAP
OPERATOR_ATTRIBUTE_IN_MAP
is the map name of the operators name suffix.
-
LOG_SQL_COMMAND_FOR_EXCEPTION
public static final SqlFeature LOG_SQL_COMMAND_FOR_EXCEPTION
LOG_SQL_COMMAND_FOR_EXCEPTION
is the indicator that in the case of an SQLException the related SQL command should be logged.
-
FILTER
public static final SqlFeature FILTER
FILTER
is the main filter in SqlProcessorLoader, if any.
-
COLLECTIONS_ARE_STANDARD_TYPES
public static final SqlFeature COLLECTIONS_ARE_STANDARD_TYPES
COLLECTIONS_ARE_STANDARD_TYPES
is indicator that Collections should be handled as standard types. This is standard behaviour for Cassandra DB.
-
SKIP_ALIASES_IN_SQL_COMMAND
public static final SqlFeature SKIP_ALIASES_IN_SQL_COMMAND
SKIP_ALIASES_IN_SQL_COMMAND
is indicator that column aliases are not included in generated SQL command. This is standard behaviour for Cassandra DB.
-
-
Method Detail
-
values
public static SqlFeature[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SqlFeature c : SqlFeature.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SqlFeature valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
-