public enum SqlSyntax extends java.lang.Enum
How a query text is read: what, besides string literals in single quotes, identifiers in double quotes or backquotes and block comments, it may hold. The syntax of native SQL is the database's, resolved from its Hibernate dialect the way RegexDialectPattern resolves the regular expression operator, so that every reader of native SQL in this package reads it as the database will. The databases differ in what a character means:
E'...' string only;$tag$...$tag$ is a string on PostgreSQL, $$...$$ on H2, and q'[...]' on Oracle;# starts a comment on MySQL, which also needs a space or a control character after --;// starts a comment on H2, and an alias may be written as a string on MySQL and SQL Server.NO_BACKSLASH_ESCAPES
and ANSI_QUOTES of MySQL, are not read from the server.
HQL has block comments only: Hibernate's parser rejects -- and //, so b.height--1 is a
subtraction there.
| Enum constant | Description |
|---|---|
DB2_NESTED_COMMENTS |
Db2 for IBM i and Db2 for z/OS: block comments nest. |
H2 |
H2: $$...$$ is a string, and // starts a comment as -- does. |
HQL |
HQL, which has block comments only, neither bracket identifiers, dollar-quoted strings nor escapes; square brackets index. |
MYSQL |
MySQL and MariaDB: a backslash escapes in a string in single or double quotes, # starts a comment, and
-- starts one only when whitespace or a control character follows. |
ORACLE |
Oracle: q'[...]', with the delimiter of choice, is a string. |
POSTGRESQL |
PostgreSQL and CockroachDB: {
|
SQL |
The SQL standard, for every other database: line comments and block comments that do not nest. |
TRANSACT_SQL |
Transact-SQL, as SQL Server and Sybase read it: [square brackets] quote an identifier, in which
]] stands for a bracket, and block comments nest. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public java.lang.Class<? extends org.hibernate.dialect.Dialect>[] |
dialectClasses() |
|
public static SqlSyntax |
forCriteriaBuilder(CriteriaBuilder criteriaBuilder)Returns the syntax of the native SQL of the database the criteria builder builds queries for, or SQL for a criteria builder that is not Hibernate's. |
|
public static SqlSyntax |
forDialect(org.hibernate.dialect.Dialect dialect)Returns the syntax of the native SQL of the database the dialect is for: SQL unless its dialect is listed. |
|
public static SqlSyntax |
forSessionFactory(org.hibernate.SessionFactory sessionFactory)Returns the syntax of the native SQL of the database the session factory connects to. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Enum |
java.lang.Enum#compareTo(java.lang.Enum), java.lang.Enum#compareTo(java.lang.Object), java.lang.Enum#describeConstable(), java.lang.Enum#equals(java.lang.Object), java.lang.Enum#getClass(), java.lang.Enum#getDeclaringClass(), java.lang.Enum#hashCode(), java.lang.Enum#name(), java.lang.Enum#notify(), java.lang.Enum#notifyAll(), java.lang.Enum#ordinal(), java.lang.Enum#toString(), java.lang.Enum#valueOf(java.lang.Class, java.lang.String), java.lang.Enum#wait(), java.lang.Enum#wait(long), java.lang.Enum#wait(long, int) |
Db2 for IBM i and Db2 for z/OS: block comments nest.
H2: $$...$$ is a string, and // starts a comment as -- does.
HQL, which has block comments only, neither bracket identifiers, dollar-quoted strings nor escapes; square brackets index.
MySQL and MariaDB: a backslash escapes in a string in single or double quotes, # starts a comment, and
-- starts one only when whitespace or a control character follows.
Oracle: q'[...]', with the delimiter of choice, is a string.
PostgreSQL and CockroachDB: $tag$...$tag$ is a string, an E'...' string escapes with a
backslash, block comments nest, and the driver reads ?? as a literal question mark.
The SQL standard, for every other database: line comments and block comments that do not nest.
Transact-SQL, as SQL Server and Sybase read it: [square brackets] quote an identifier, in which
]] stands for a bracket, and block comments nest.
Returns the syntax of the native SQL of the database the criteria builder builds queries for, or SQL for a criteria builder that is not Hibernate's.
Returns the syntax of the native SQL of the database the dialect is for: SQL unless its dialect is listed.
Returns the syntax of the native SQL of the database the session factory connects to.