From a8a9864a609530ff97546cd67b4d6f8968954f8d Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 28 Sep 2015 17:35:10 +0100 Subject: [PATCH] HHH-10142 - Add SQL keyword to DerbyDialect --- .../org/hibernate/dialect/DerbyDialect.java | 213 +++++++++++++++++- 1 file changed, 212 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index c9fca033dc..6839b9a636 100755 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -18,7 +18,6 @@ import org.hibernate.dialect.function.DerbyConcatFunction; import org.hibernate.dialect.pagination.AbstractLimitHandler; import org.hibernate.dialect.pagination.LimitHandler; import org.hibernate.dialect.pagination.LimitHelper; -import org.hibernate.engine.jdbc.env.spi.AnsiSqlKeywords; import org.hibernate.engine.jdbc.env.spi.IdentifierHelper; import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder; import org.hibernate.engine.spi.RowSelection; @@ -64,6 +63,7 @@ public class DerbyDialect extends DB2Dialect { registerFunction( "concat", new DerbyConcatFunction() ); registerFunction( "trim", new AnsiTrimFunction() ); registerColumnType( Types.BLOB, "blob" ); + registerDerbyKeywords(); determineDriverVersion(); if ( driverVersionMajor > 10 || ( driverVersionMajor == 10 && driverVersionMinor >= 7 ) ) { @@ -341,10 +341,221 @@ public class DerbyDialect extends DB2Dialect { builder.applyIdentifierCasing( dbMetaData ); builder.applyReservedWords( dbMetaData ); + builder.applyReservedWords( getKeywords() ); builder.setNameQualifierSupport( getNameQualifierSupport() ); return builder.build(); } + + protected void registerDerbyKeywords() { + registerKeyword( "ADD" ); + registerKeyword( "ALL" ); + registerKeyword( "ALLOCATE" ); + registerKeyword( "ALTER" ); + registerKeyword( "AND" ); + registerKeyword( "ANY" ); + registerKeyword( "ARE" ); + registerKeyword( "AS" ); + registerKeyword( "ASC" ); + registerKeyword( "ASSERTION" ); + registerKeyword( "AT" ); + registerKeyword( "AUTHORIZATION" ); + registerKeyword( "AVG" ); + registerKeyword( "BEGIN" ); + registerKeyword( "BETWEEN" ); + registerKeyword( "BIT" ); + registerKeyword( "BOOLEAN" ); + registerKeyword( "BOTH" ); + registerKeyword( "BY" ); + registerKeyword( "CALL" ); + registerKeyword( "CASCADE" ); + registerKeyword( "CASCADED" ); + registerKeyword( "CASE" ); + registerKeyword( "CAST" ); + registerKeyword( "CHAR" ); + registerKeyword( "CHARACTER" ); + registerKeyword( "CHECK" ); + registerKeyword( "CLOSE" ); + registerKeyword( "COLLATE" ); + registerKeyword( "COLLATION" ); + registerKeyword( "COLUMN" ); + registerKeyword( "COMMIT" ); + registerKeyword( "CONNECT" ); + registerKeyword( "CONNECTION" ); + registerKeyword( "CONSTRAINT" ); + registerKeyword( "CONSTRAINTS" ); + registerKeyword( "CONTINUE" ); + registerKeyword( "CONVERT" ); + registerKeyword( "CORRESPONDING" ); + registerKeyword( "COUNT" ); + registerKeyword( "CREATE" ); + registerKeyword( "CURRENT" ); + registerKeyword( "CURRENT_DATE" ); + registerKeyword( "CURRENT_TIME" ); + registerKeyword( "CURRENT_TIMESTAMP" ); + registerKeyword( "CURRENT_USER" ); + registerKeyword( "CURSOR" ); + registerKeyword( "DEALLOCATE" ); + registerKeyword( "DEC" ); + registerKeyword( "DECIMAL" ); + registerKeyword( "DECLARE" ); + registerKeyword( "DEFERRABLE" ); + registerKeyword( "DEFERRED" ); + registerKeyword( "DELETE" ); + registerKeyword( "DESC" ); + registerKeyword( "DESCRIBE" ); + registerKeyword( "DIAGNOSTICS" ); + registerKeyword( "DISCONNECT" ); + registerKeyword( "DISTINCT" ); + registerKeyword( "DOUBLE" ); + registerKeyword( "DROP" ); + registerKeyword( "ELSE" ); + registerKeyword( "END" ); + registerKeyword( "ENDEXEC" ); + registerKeyword( "ESCAPE" ); + registerKeyword( "EXCEPT" ); + registerKeyword( "EXCEPTION" ); + registerKeyword( "EXEC" ); + registerKeyword( "EXECUTE" ); + registerKeyword( "EXISTS" ); + registerKeyword( "EXPLAIN" ); + registerKeyword( "EXTERNAL" ); + registerKeyword( "FALSE" ); + registerKeyword( "FETCH" ); + registerKeyword( "FIRST" ); + registerKeyword( "FLOAT" ); + registerKeyword( "FOR" ); + registerKeyword( "FOREIGN" ); + registerKeyword( "FOUND" ); + registerKeyword( "FROM" ); + registerKeyword( "FULL" ); + registerKeyword( "FUNCTION" ); + registerKeyword( "GET" ); + registerKeyword( "GET_CURRENT_CONNECTION" ); + registerKeyword( "GLOBAL" ); + registerKeyword( "GO" ); + registerKeyword( "GOTO" ); + registerKeyword( "GRANT" ); + registerKeyword( "GROUP" ); + registerKeyword( "HAVING" ); + registerKeyword( "HOUR" ); + registerKeyword( "IDENTITY" ); + registerKeyword( "IMMEDIATE" ); + registerKeyword( "IN" ); + registerKeyword( "INDICATOR" ); + registerKeyword( "INITIALLY" ); + registerKeyword( "INNER" ); + registerKeyword( "INOUT" ); + registerKeyword( "INPUT" ); + registerKeyword( "INSENSITIVE" ); + registerKeyword( "INSERT" ); + registerKeyword( "INT" ); + registerKeyword( "INTEGER" ); + registerKeyword( "INTERSECT" ); + registerKeyword( "INTO" ); + registerKeyword( "IS" ); + registerKeyword( "ISOLATION" ); + registerKeyword( "JOIN" ); + registerKeyword( "KEY" ); + registerKeyword( "LAST" ); + registerKeyword( "LEFT" ); + registerKeyword( "LIKE" ); + registerKeyword( "LONGINT" ); + registerKeyword( "LOWER" ); + registerKeyword( "LTRIM" ); + registerKeyword( "MATCH" ); + registerKeyword( "MAX" ); + registerKeyword( "MIN" ); + registerKeyword( "MINUTE" ); + registerKeyword( "NATIONAL" ); + registerKeyword( "NATURAL" ); + registerKeyword( "NCHAR" ); + registerKeyword( "NVARCHAR" ); + registerKeyword( "NEXT" ); + registerKeyword( "NO" ); + registerKeyword( "NOT" ); + registerKeyword( "NULL" ); + registerKeyword( "NULLIF" ); + registerKeyword( "NUMERIC" ); + registerKeyword( "OF" ); + registerKeyword( "ON" ); + registerKeyword( "ONLY" ); + registerKeyword( "OPEN" ); + registerKeyword( "OPTION" ); + registerKeyword( "OR" ); + registerKeyword( "ORDER" ); + registerKeyword( "OUT" ); + registerKeyword( "OUTER" ); + registerKeyword( "OUTPUT" ); + registerKeyword( "OVERLAPS" ); + registerKeyword( "PAD" ); + registerKeyword( "PARTIAL" ); + registerKeyword( "PREPARE" ); + registerKeyword( "PRESERVE" ); + registerKeyword( "PRIMARY" ); + registerKeyword( "PRIOR" ); + registerKeyword( "PRIVILEGES" ); + registerKeyword( "PROCEDURE" ); + registerKeyword( "PUBLIC" ); + registerKeyword( "READ" ); + registerKeyword( "REAL" ); + registerKeyword( "REFERENCES" ); + registerKeyword( "RELATIVE" ); + registerKeyword( "RESTRICT" ); + registerKeyword( "REVOKE" ); + registerKeyword( "RIGHT" ); + registerKeyword( "ROLLBACK" ); + registerKeyword( "ROWS" ); + registerKeyword( "RTRIM" ); + registerKeyword( "SCHEMA" ); + registerKeyword( "SCROLL" ); + registerKeyword( "SECOND" ); + registerKeyword( "SELECT" ); + registerKeyword( "SESSION_USER" ); + registerKeyword( "SET" ); + registerKeyword( "SMALLINT" ); + registerKeyword( "SOME" ); + registerKeyword( "SPACE" ); + registerKeyword( "SQL" ); + registerKeyword( "SQLCODE" ); + registerKeyword( "SQLERROR" ); + registerKeyword( "SQLSTATE" ); + registerKeyword( "SUBSTR" ); + registerKeyword( "SUBSTRING" ); + registerKeyword( "SUM" ); + registerKeyword( "SYSTEM_USER" ); + registerKeyword( "TABLE" ); + registerKeyword( "TEMPORARY" ); + registerKeyword( "TIMEZONE_HOUR" ); + registerKeyword( "TIMEZONE_MINUTE" ); + registerKeyword( "TO" ); + registerKeyword( "TRAILING" ); + registerKeyword( "TRANSACTION" ); + registerKeyword( "TRANSLATE" ); + registerKeyword( "TRANSLATION" ); + registerKeyword( "TRUE" ); + registerKeyword( "UNION" ); + registerKeyword( "UNIQUE" ); + registerKeyword( "UNKNOWN" ); + registerKeyword( "UPDATE" ); + registerKeyword( "UPPER" ); + registerKeyword( "USER" ); + registerKeyword( "USING" ); + registerKeyword( "VALUES" ); + registerKeyword( "VARCHAR" ); + registerKeyword( "VARYING" ); + registerKeyword( "VIEW" ); + registerKeyword( "WHENEVER" ); + registerKeyword( "WHERE" ); + registerKeyword( "WITH" ); + registerKeyword( "WORK" ); + registerKeyword( "WRITE" ); + registerKeyword( "XML" ); + registerKeyword( "XMLEXISTS" ); + registerKeyword( "XMLPARSE" ); + registerKeyword( "XMLSERIALIZE" ); + registerKeyword( "YEAR" ); + } }