HHH-16430 Small optimisation in Dialect initializations

This commit is contained in:
Sanne Grinovero 2023-04-03 17:07:55 +01:00 committed by Sanne Grinovero
parent 845e9770d5
commit a5315c7e50
2 changed files with 251 additions and 250 deletions

View File

@ -610,9 +610,10 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
*/
protected void registerDefaultKeywords() {
AnsiSqlKeywords keywords = new AnsiSqlKeywords();
for ( String keyword : keywords.sql2003() ) {
registerKeyword( keyword );
}
//Not using #registerKeyword as:
// # these are already lowercase
// # better efficiency of addAll as it can pre-size the collections
sqlKeywords.addAll( keywords.sql2003() );
}
/**

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.engine.jdbc.env.spi;
import java.util.Set;
import java.util.List;
/**
* Maintains the set of ANSI SQL keywords
@ -15,253 +15,253 @@ import java.util.Set;
*/
public final class AnsiSqlKeywords {
private final Set<String> keywordsSql2003;
private final List<String> keywordsSql2003;
public AnsiSqlKeywords() {
this.keywordsSql2003 = Set.of(
"add",
"all",
"allocate",
"alter",
"and",
"any",
"are",
"array",
"as",
"asensitive",
"asymmetric",
"at",
"atomic",
"authorization",
"begin",
"between",
"bigint",
"blob",
"binary",
"both",
"by",
"call",
"called",
"cascaded",
"case",
"cast",
"char",
"character",
"check",
"clob",
"close",
"collate",
"column",
"commit",
"condition",
"connect",
"constraint",
"continue",
"corresponding",
"create",
"cross",
"cube",
"current",
"current_date",
"current_path",
"current_role",
"current_time",
"current_timestamp",
"current_user",
"cursor",
"cycle",
"date",
"day",
"deallocate",
"dec",
"decimal",
"declare",
"default",
"delete",
"deref",
"describe",
"deterministic",
"disconnect",
"distinct",
"do",
"double",
"drop",
"dynamic",
"each",
"element",
"else",
"elsif",
"end",
"escape",
"except",
"exec",
"execute",
"exists",
"exit",
"external",
"false",
"fetch",
"filter",
"float",
"for",
"foreign",
"free",
"from",
"full",
"function",
"get",
"global",
"grant",
"group",
"grouping",
"handler",
"having",
"hold",
"hour",
"identity",
"if",
"immediate",
"in",
"indicator",
"inner",
"inout",
"input",
"insensitive",
"insert",
"int",
"integer",
"intersect",
"interval",
"into",
"is",
"iterate",
"join",
"language",
"large",
"lateral",
"leading",
"leave",
"left",
"like",
"local",
"localtime",
"localtimestamp",
"loop",
"match",
"member",
"merge",
"method",
"minute",
"modifies",
"module",
"month",
"multiset",
"national",
"natural",
"nchar",
"nclob",
"new",
"no",
"none",
"not",
"null",
"numeric",
"of",
"old",
"on",
"only",
"open",
"or",
"order",
"out",
"outer",
"output",
"over",
"overlaps",
"parameter",
"partition",
"precision",
"prepare",
"primary",
"procedure",
"range",
"reads",
"real",
"recursive",
"ref",
"references",
"referencing",
"release",
"repeat",
"resignal",
"result",
"return",
"returns",
"revoke",
"right",
"rollback",
"rollup",
"row",
"rows",
"savepoint",
"scroll",
"search",
"second",
"select",
"sensitive",
"session_use",
"set",
"signal",
"similar",
"smallint",
"some",
"specific",
"specifictype",
"sql",
"sqlexception",
"sqlstate",
"sqlwarning",
"start",
"static",
"submultiset",
"symmetric",
"system",
"system_user",
"table",
"tablesample",
"then",
"time",
"timestamp",
"timezone_hour",
"timezone_minute",
"to",
"trailing",
"translation",
"treat",
"trigger",
"true",
"undo",
"union",
"unique",
"unknown",
"unnest",
"until",
"update",
"user",
"using",
"value",
"values",
"varchar",
"varying",
"when",
"whenever",
"where",
"while",
"window",
"with",
"within",
"without",
"year");
this.keywordsSql2003 = List.of(
"add",
"all",
"allocate",
"alter",
"and",
"any",
"are",
"array",
"as",
"asensitive",
"asymmetric",
"at",
"atomic",
"authorization",
"begin",
"between",
"bigint",
"blob",
"binary",
"both",
"by",
"call",
"called",
"cascaded",
"case",
"cast",
"char",
"character",
"check",
"clob",
"close",
"collate",
"column",
"commit",
"condition",
"connect",
"constraint",
"continue",
"corresponding",
"create",
"cross",
"cube",
"current",
"current_date",
"current_path",
"current_role",
"current_time",
"current_timestamp",
"current_user",
"cursor",
"cycle",
"date",
"day",
"deallocate",
"dec",
"decimal",
"declare",
"default",
"delete",
"deref",
"describe",
"deterministic",
"disconnect",
"distinct",
"do",
"double",
"drop",
"dynamic",
"each",
"element",
"else",
"elsif",
"end",
"escape",
"except",
"exec",
"execute",
"exists",
"exit",
"external",
"false",
"fetch",
"filter",
"float",
"for",
"foreign",
"free",
"from",
"full",
"function",
"get",
"global",
"grant",
"group",
"grouping",
"handler",
"having",
"hold",
"hour",
"identity",
"if",
"immediate",
"in",
"indicator",
"inner",
"inout",
"input",
"insensitive",
"insert",
"int",
"integer",
"intersect",
"interval",
"into",
"is",
"iterate",
"join",
"language",
"large",
"lateral",
"leading",
"leave",
"left",
"like",
"local",
"localtime",
"localtimestamp",
"loop",
"match",
"member",
"merge",
"method",
"minute",
"modifies",
"module",
"month",
"multiset",
"national",
"natural",
"nchar",
"nclob",
"new",
"no",
"none",
"not",
"null",
"numeric",
"of",
"old",
"on",
"only",
"open",
"or",
"order",
"out",
"outer",
"output",
"over",
"overlaps",
"parameter",
"partition",
"precision",
"prepare",
"primary",
"procedure",
"range",
"reads",
"real",
"recursive",
"ref",
"references",
"referencing",
"release",
"repeat",
"resignal",
"result",
"return",
"returns",
"revoke",
"right",
"rollback",
"rollup",
"row",
"rows",
"savepoint",
"scroll",
"search",
"second",
"select",
"sensitive",
"session_use",
"set",
"signal",
"similar",
"smallint",
"some",
"specific",
"specifictype",
"sql",
"sqlexception",
"sqlstate",
"sqlwarning",
"start",
"static",
"submultiset",
"symmetric",
"system",
"system_user",
"table",
"tablesample",
"then",
"time",
"timestamp",
"timezone_hour",
"timezone_minute",
"to",
"trailing",
"translation",
"treat",
"trigger",
"true",
"undo",
"union",
"unique",
"unknown",
"unnest",
"until",
"update",
"user",
"using",
"value",
"values",
"varchar",
"varying",
"when",
"whenever",
"where",
"while",
"window",
"with",
"within",
"without",
"year");
}
/**
@ -270,7 +270,7 @@ public final class AnsiSqlKeywords {
*
* @return ANSI SQL:2003 keywords
*/
public Set<String> sql2003() {
public List<String> sql2003() {
return keywordsSql2003;
}