Package net.sf.jkniv.sqlegance.dialect
Class AnsiDialect
- java.lang.Object
-
- net.sf.jkniv.sqlegance.dialect.AnsiDialect
-
- All Implemented Interfaces:
SqlDialect
public class AnsiDialect extends Object implements SqlDialect
Represents the support from SQL ANSI that are queries cross-platform. Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility with different systems. Subclasses should provide a public default constructor that register a set of type mappings and default Hibernate properties. Subclasses should be immutable.- Supports limits? false
- Supports limit off set? false
- Supports rownum? false
- Author:
- Alisson Gomes
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringnamestatic PatternpatternORDER_BY
-
Constructor Summary
Constructors Constructor Description AnsiDialect()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlFeatureaddFeature(SqlFeature sqlFeature)Override a SQL ANSI featureStringbuildQueryCount(String sqlText)Build a paginate query to count the total of records fromsqlTextStringbuildQueryPaging(String sqlText, int offset, int max)Build a paginate query accordingly data base dialectStringbuildQueryPaging(String sqlText, int offset, int max, String bookmark)Build a paginate query accordingly data base dialectprotected intcountOccurrencesOf(String str, String sub)Count the occurrences of the substring in string s.net.sf.jkniv.reflect.beans.PropertyAccessgetAccessId()The access name foridfield, the identifier from an entitynet.sf.jkniv.reflect.beans.PropertyAccessgetAccessRevision()The access name forrevisionfield, a revision number from an entityintgetMaxOfParameters()Return the limit of elements in anINPUTparameter the database supports.StringgetSqlPatternCount()The template to mount theCOUNTSQLStringgetSqlPatternPaging()The template to mount the SQL paginated, using LIMIT and OFFSET clauses according the specific databaseStringname()Dialect namevoidsetMaxOfParameters(int max)Max number of parameters supported by JDBC driverprotected MatchersqlEndsWithOrderBy(String sql)protected MatchersqlEndWithForUpdate(String sql)protected MatchersqlStartWithSelect(String sql)protected MatchersqlStartWithSelectOrDistinct(String sql)booleansupportsFeature(SqlFeatureSupport feature)verify if dialect instance supportsfeaturespecifiedbooleansupportsParmMark(ParamMarkType paramParse)verify if dialect supports a specificParamMarkType
-
-
-
Method Detail
-
name
public String name()
Description copied from interface:SqlDialectDialect name- Specified by:
namein interfaceSqlDialect- Returns:
- the dialect name
-
supportsFeature
public boolean supportsFeature(SqlFeatureSupport feature)
Description copied from interface:SqlDialectverify if dialect instance supportsfeaturespecified- Specified by:
supportsFeaturein interfaceSqlDialect- Parameters:
feature- to check- Returns:
truewhen the dialect supports,falseotherwise
-
supportsParmMark
public boolean supportsParmMark(ParamMarkType paramParse)
Description copied from interface:SqlDialectverify if dialect supports a specificParamMarkType- Specified by:
supportsParmMarkin interfaceSqlDialect- Parameters:
paramParse- parameter mark type- Returns:
truewhen the parse type is supported,falseotherwise
-
addFeature
public SqlFeature addFeature(SqlFeature sqlFeature)
Description copied from interface:SqlDialectOverride a SQL ANSI feature- Specified by:
addFeaturein interfaceSqlDialect- Parameters:
sqlFeature- override aSqlFeaturesupports.- Returns:
- the previous value associated with key
sqlFeature
-
getMaxOfParameters
public int getMaxOfParameters()
Description copied from interface:SqlDialectReturn the limit of elements in anINPUTparameter the database supports.- Specified by:
getMaxOfParametersin interfaceSqlDialect- Returns:
- the limit of parameters from statement, default is a big number
Integer.MAX_VALUE
-
setMaxOfParameters
public void setMaxOfParameters(int max)
Description copied from interface:SqlDialectMax number of parameters supported by JDBC driver- Specified by:
setMaxOfParametersin interfaceSqlDialect- Parameters:
max- maximum value of parameter in the query
-
getSqlPatternCount
public String getSqlPatternCount()
Description copied from interface:SqlDialectThe template to mount theCOUNTSQL- Specified by:
getSqlPatternCountin interfaceSqlDialect- Returns:
- a string template, like that:
select count(1) from (%1$s) _alias_internal_table_
-
getSqlPatternPaging
public String getSqlPatternPaging()
Description copied from interface:SqlDialectThe template to mount the SQL paginated, using LIMIT and OFFSET clauses according the specific database- Specified by:
getSqlPatternPagingin interfaceSqlDialect- Returns:
- a string template, like that:
%1$s LIMIT %2$s, %3$s
-
buildQueryPaging
public String buildQueryPaging(String sqlText, int offset, int max)
Description copied from interface:SqlDialectBuild a paginate query accordingly data base dialect- Specified by:
buildQueryPagingin interfaceSqlDialect- Parameters:
sqlText- final SQL with parameters to bindoffset- number from first row from query resultmax- maximum number of rows from query result.- Returns:
- paginate query for specific data base dialect
-
buildQueryPaging
public String buildQueryPaging(String sqlText, int offset, int max, String bookmark)
Description copied from interface:SqlDialectBuild a paginate query accordingly data base dialect- Specified by:
buildQueryPagingin interfaceSqlDialect- Parameters:
sqlText- final SQL with parameters to bindoffset- number from first row from query resultmax- maximum number of rows from query result.bookmark- a page selected marked the reader's place- Returns:
- paginate query for specific data base dialect
-
getAccessId
public net.sf.jkniv.reflect.beans.PropertyAccess getAccessId()
Description copied from interface:SqlDialectThe access name foridfield, the identifier from an entity- Specified by:
getAccessIdin interfaceSqlDialect- Returns:
- the property access, default access values are:
id,getId,setId
-
getAccessRevision
public net.sf.jkniv.reflect.beans.PropertyAccess getAccessRevision()
Description copied from interface:SqlDialectThe access name forrevisionfield, a revision number from an entity- Specified by:
getAccessRevisionin interfaceSqlDialect- Returns:
- the property access, default access values are:
rev,getRev,setRev
-
buildQueryCount
public String buildQueryCount(String sqlText)
Description copied from interface:SqlDialectBuild a paginate query to count the total of records fromsqlText- Specified by:
buildQueryCountin interfaceSqlDialect- Parameters:
sqlText- original SQL to discover the total of records- Returns:
- query that count the total of records from
sqlText
-
-