Package net.sf.jkniv.sqlegance
Interface Sql
-
- All Known Subinterfaces:
Deletable,Insertable,Selectable,SqlTag,Updateable
- All Known Implementing Classes:
AbstractSqlTag,IncludeTag,ProcedureTag
public interface SqlThis interface represent Structured Query Language (SQL and some derivations like JPQL, HQL, JPQL, CQL...) in XML file, each node at XML file is represented by this class.Those queries can be dynamic or static and to recover a dynamic query (built on-the-fly) is necessary to pass the parameters that can be mounted dynamically.
- Since:
- 0.6.0
- Author:
- Alisson Gomes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DeletableasDeletable()DeletableinstanceInsertableasInsertable()InsertableinstanceSelectableasSelectable()SelectableinstanceStorableasStorable()StorableinstanceUpdateableasUpdateable()Updateableinstancevoidbind(SqlDialect sqlDialect)String[]extractNames(Object params)Extract the name parameters from dynamic queryString[]extractNames(String sql)Extract the name parameters from SQLIsolationgetIsolation()Retrieves the current transaction isolation level for the query.LanguageTypegetLanguageType()Retrieve the language type used at sql sentence.StringgetName()The name of query into XML fileStringgetPackage()name of package that this SQL belongsParamParsergetParamParser()strategy to parser the parameters from SQL.StringgetResourceName()The filename that SQL belong toResultSetConcurrencygetResultSetConcurrency()ResultSetHoldabilitygetResultSetHoldability()ResultSetTypegetResultSetType()StringgetReturnType()Class<?>getReturnTypeAsClass()StringgetSql()Retrieve static SQL from a node, the dynamic parts is skipped.StringgetSql(Object params)Retrieve dynamic SQL from a node, the dynamic parts is evaluated at time to create the SQL.SqlDialectgetSqlDialect()dialect for a specific databaseSqlTypegetSqlType()Retrieve node type: INSERT, UPDATE, DELETE, SELECT or PROCEDURE.StatisticalgetStats()get statistical data from query executionintgetTimeout()Retrieves the number of seconds the repository will wait for a Query object to execute.DategetTimestamp()Timestamp when sql was read from xmlValidateTypegetValidateType()StringgetXPath()Expression XPATH to read SQLbooleanhasReturnType()booleanisDeletable()Verify if command is a DELETEbooleanisInsertable()Verify if command is a INSERTbooleanisSelectable()Verify if command is a SELECTbooleanisStorable()Verify if command is a STORED PROCEDUREbooleanisUpdateable()Verify if command is a UPDATEvoidsetValidateType(ValidateType validateType)
-
-
-
Method Detail
-
getName
String getName()
The name of query into XML file- Returns:
- query name
-
getSql
String getSql()
Retrieve static SQL from a node, the dynamic parts is skipped.- Returns:
- SQL sentence
-
getSql
String getSql(Object params)
Retrieve dynamic SQL from a node, the dynamic parts is evaluated at time to create the SQL.- Parameters:
params- parameters to evaluate dynamic SQL, can be a object like Author, Book, etc or a java.util.Map where yours keys is like the properties.- Returns:
- Dynamic SQL sentence
-
getSqlType
SqlType getSqlType()
Retrieve node type: INSERT, UPDATE, DELETE, SELECT or PROCEDURE.- Returns:
- node type declared at XML file.
-
isSelectable
boolean isSelectable()
Verify if command is a SELECT- Returns:
truewhen is SELECT,falseotherwise
-
asSelectable
Selectable asSelectable()
Selectableinstance- Returns:
- this instance
- Throws:
UnsupportedOperationException- when this instance isn'tSelectable
-
isInsertable
boolean isInsertable()
Verify if command is a INSERT- Returns:
truewhen is INSERT,falseotherwise
-
asInsertable
Insertable asInsertable()
Insertableinstance- Returns:
- this instance
- Throws:
UnsupportedOperationException- when this instance isn'tInsertable
-
isUpdateable
boolean isUpdateable()
Verify if command is a UPDATE- Returns:
truewhen is UPDATE,falseotherwise
-
asUpdateable
Updateable asUpdateable()
Updateableinstance- Returns:
- this instance
- Throws:
UnsupportedOperationException- when this instance isn'tUpdateable
-
isDeletable
boolean isDeletable()
Verify if command is a DELETE- Returns:
truewhen is DELETE,falseotherwise
-
asDeletable
Deletable asDeletable()
Deletableinstance- Returns:
- this instance
- Throws:
UnsupportedOperationException- when this instance isn'tDeletable
-
isStorable
boolean isStorable()
Verify if command is a STORED PROCEDURE- Returns:
truewhen is STORED PROCEDURE,falseotherwise
-
asStorable
Storable asStorable()
Storableinstance- Returns:
- this instance
- Throws:
UnsupportedOperationException- when this instance isn'tStorable
-
getLanguageType
LanguageType getLanguageType()
Retrieve the language type used at sql sentence.- Returns:
- language type declared at xml file.
-
getIsolation
Isolation getIsolation()
Retrieves the current transaction isolation level for the query.- Returns:
- the current transaction isolation level.
-
getTimeout
int getTimeout()
Retrieves the number of seconds the repository will wait for a Query object to execute. If the limit is exceeded, a RepositoryException is thrown.- Returns:
- the current query timeout limit in seconds; zero means there is no limit
-
getResultSetType
ResultSetType getResultSetType()
-
getResultSetConcurrency
ResultSetConcurrency getResultSetConcurrency()
-
getResultSetHoldability
ResultSetHoldability getResultSetHoldability()
-
getReturnType
String getReturnType()
-
hasReturnType
boolean hasReturnType()
-
getReturnTypeAsClass
Class<?> getReturnTypeAsClass()
-
getTimestamp
Date getTimestamp()
Timestamp when sql was read from xml- Returns:
- when SQL was read from XML file
-
getResourceName
String getResourceName()
The filename that SQL belong to- Returns:
- return the filename, relative to absolute classpath, where the SQL was read.
-
getXPath
String getXPath()
Expression XPATH to read SQL- Returns:
- the XPATH expression to read the SQL at XML file.
-
getParamParser
ParamParser getParamParser()
strategy to parser the parameters from SQL.- Returns:
- return the implementation of parser (colon, hash or question mark)
-
extractNames
String[] extractNames(Object params)
Extract the name parameters from dynamic query- Parameters:
params- parameters from query- Returns:
- array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
-
extractNames
String[] extractNames(String sql)
Extract the name parameters from SQL- Parameters:
sql- sentence- Returns:
- array of parameters names from query, array based-zero length when haven't param. Array of questions marks (?) is returned when the isn't name based.
-
getValidateType
ValidateType getValidateType()
-
setValidateType
void setValidateType(ValidateType validateType)
-
bind
void bind(SqlDialect sqlDialect)
-
getSqlDialect
SqlDialect getSqlDialect()
dialect for a specific database- Returns:
- the dialect
-
getPackage
String getPackage()
name of package that this SQL belongs- Returns:
- name of package
-
getStats
Statistical getStats()
get statistical data from query execution- Returns:
- the statistical like min/max/avg times.
-
-