Enum Class SqlFeature
- All Implemented Interfaces:
Serializable
,Comparable<SqlFeature>
,Constable
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 key LIKE_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 key
WILDCARD_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 key SURROUND_QUERY_MIN_LEN
.
In the case of SQL Processor initialization
JdbcEngineFactory 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 name
LIKE_PEOPLE
.
Next there's an instance person of the class Person with the value an
for the attribute name. The
invocation
Person person = new Person(); person.setName("jan"); 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 DESCIn the result list there are all table rows with name, which contains the text fragment
jan
.
For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe filter for Cassandra devoted optional features.COLLECTIONS_ARE_STANDARD_TYPES
is indicator that Collections should be handled as standard types.The filter for DB2 Server devoted optional features.EMPTY_FOR_NULL
is indicator that the NULL values are always empty.EMPTY_USE_METHOD_IS_NULL
is indicator that the non-emptiness depends the special isNull method.FILTER
is the main filter in SqlProcessorLoader, if any.The filter for H2 devoted optional features.The filter for HSQLDB devoted optional features.ID
is the key for the identity columns.IDGEN
is the key for the SQL query pattern used to obtain the value of identities or sequences.IDSEL
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IDSEL_Integer
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IDSEL_Long
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command.IGNORE_INPROPER_IN
is the key for special handling of input/output values.IGNORE_INPROPER_OUT
is the key for special handling of input/output values.The filter for Informix devoted optional features.JDBC
is the key for the raw JDBC stack usage.LIKE_STRING
is the key for the SQL commandlike
.LIMIT_FROM_TO
is the key for the SQL query pattern used to limit the query results.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
is the key for the SQL query pattern used to limit the query results.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
is the indicator that in the case of an SQLException the related SQL command should be logged.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
lists the methods used in the translation from a JDBC datatype to a Java type for enumerations based output values.The filter for MS SQL Server devoted optional features.The filter for MySQL devoted optional features.OPERATOR_ATTRIBUTE
is the operator atribute name suffix.OPERATOR_ATTRIBUTE_IN_MAP
is the map name of the operators name suffix.The filter for Oracle devoted optional features.The filter for PostgreSQL devoted optional features.REPLACE_LIKE_CHARS
is the key for the special SQL Processor behavior related to the SQL commandlike
.REPLACE_LIKE_STRING
is the key for the special SQL Processor behavior related to the SQL commandlike
.SEQ
is the key for the SQL query pattern used for the sequences.SEQ_NAME
is the key for the sequence name.SKIP_ALIASES_IN_SQL_COMMAND
is indicator that column aliases are not included in generated SQL command.SURROUND_QUERY_LIKE
is the key for the special SQL Processor behavior.SURROUND_QUERY_LIKE_PARTIAL
is the key for the special SQL Processor behavior.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
is the key for the version column name.WILDCARD_CHARACTER
is the key for the wildcard character for the SQLlike
command. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlFeature
Returns the enum constant of this class with the specified name.static SqlFeature[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ORACLE
The filter for Oracle devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
HSQLDB
The filter for HSQLDB devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
MYSQL
The filter for MySQL devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
POSTGRESQL
The filter for PostgreSQL devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
INFORMIX
The filter for Informix devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
MSSQL
The filter for MS SQL Server devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
DB2
The filter for DB2 Server devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
H2
The filter for H2 devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
CASSANDRA
The filter for Cassandra devoted optional features. It can be used for the construction ofSqlProcessorLoader
. -
WILDCARD_CHARACTER
WILDCARD_CHARACTER
is the key for the wildcard character for the SQLlike
command. -
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
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
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
LIKE_STRING
is the key for the SQL commandlike
. For example for the Informix database it can bematches
. -
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
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
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. -
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
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
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
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
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
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
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
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
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
SEQ_NAME
is the key for the sequence name. -
IDSEL
IDSEL
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. -
IDSEL_Integer
IDSEL_Integer
is the key for the SQL query pattern used to obtain the value of identities after the INSERT command. -
IDGEN
IDGEN
is the key for the SQL query pattern used to obtain the value of identities or sequences. -
VERSION_COLUMN
VERSION_COLUMN
is the key for the version column name. -
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
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
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. -
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
FILTER
is the main filter in SqlProcessorLoader, if any. -
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
SKIP_ALIASES_IN_SQL_COMMAND
is indicator that column aliases are not included in generated SQL command. This is standard behaviour for Cassandra DB.
-
-
Constructor Details
-
SqlFeature
private SqlFeature()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-