Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c7e9dcc9
提交
c7e9dcc9
authored
7月 15, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
07236a50
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
49 行增加
和
31 行删除
+49
-31
roadmap.html
h2/src/docsrc/html/roadmap.html
+1
-0
H2Dialect.java.txt
h2/src/tools/org/hibernate/dialect/H2Dialect.java.txt
+48
-31
没有找到文件。
h2/src/docsrc/html/roadmap.html
浏览文件 @
c7e9dcc9
...
@@ -371,6 +371,7 @@ Roadmap
...
@@ -371,6 +371,7 @@ Roadmap
</li><li>
Support large databases: split LOB (BLOB, CLOB) to multiple directories / disks (similar to tablespaces).
</li><li>
Support large databases: split LOB (BLOB, CLOB) to multiple directories / disks (similar to tablespaces).
</li><li>
Support to assign a primary key index a user defined name.
</li><li>
Support to assign a primary key index a user defined name.
</li><li>
Cluster: Add feature to make sure cluster nodes can not get out of sync (for example by stopping one process).
</li><li>
Cluster: Add feature to make sure cluster nodes can not get out of sync (for example by stopping one process).
</li><lil>
H2 Console: support configuration option for fixed width (monospace) font.
</li></ul>
</li></ul>
<h2>
Not Planned
</h2>
<h2>
Not Planned
</h2>
...
...
h2/src/tools/org/hibernate/dialect/H2Dialect.java.txt
浏览文件 @
c7e9dcc9
...
@@ -14,22 +14,33 @@ import org.hibernate.util.ReflectHelper;
...
@@ -14,22 +14,33 @@ import org.hibernate.util.ReflectHelper;
/**
/**
* A dialect compatible with the H2 database.
* A dialect compatible with the H2 database.
*
*
* @author Thomas Mueller
* @author Thomas Mueller
*
*
*/
*/
public class H2Dialect extends Dialect {
public class H2Dialect extends Dialect {
private String querySequenceString;
private String querySequenceString;
public H2Dialect() {
public H2Dialect() {
super();
super();
querySequenceString = "select sequence_name from information_schema.sequences";
querySequenceString = "select sequence_name from information_schema.sequences";
try {
// HHH-2300
Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null);
int buildid = build.intValue();
if(buildid < 32) {
querySequenceString = "select name from information_schema.sequences";
}
} catch(Throwable e) {
// ignore (probably H2 not in the classpath)
}
registerColumnType(Types.BOOLEAN, "boolean");
registerColumnType(Types.BOOLEAN, "boolean");
registerColumnType(Types.BIGINT, "bigint");
registerColumnType(Types.BIGINT, "bigint");
registerColumnType(Types.BINARY, "binary");
registerColumnType(Types.BINARY, "binary");
registerColumnType(Types.BIT, "boolean");
registerColumnType(Types.BIT, "boolean");
registerColumnType(Types.CHAR, "
var
char($l)");
registerColumnType(Types.CHAR, "char($l)");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.DATE, "date");
registerColumnType(Types.DECIMAL, "decimal($p,$s)");
registerColumnType(Types.DECIMAL, "decimal($p,$s)");
registerColumnType(Types.DOUBLE, "double");
registerColumnType(Types.DOUBLE, "double");
...
@@ -37,7 +48,7 @@ public class H2Dialect extends Dialect {
...
@@ -37,7 +48,7 @@ public class H2Dialect extends Dialect {
registerColumnType(Types.INTEGER, "integer");
registerColumnType(Types.INTEGER, "integer");
registerColumnType(Types.LONGVARBINARY, "longvarbinary");
registerColumnType(Types.LONGVARBINARY, "longvarbinary");
registerColumnType(Types.LONGVARCHAR, "longvarchar");
registerColumnType(Types.LONGVARCHAR, "longvarchar");
registerColumnType(Types.REAL, "real");
registerColumnType(Types.REAL, "real");
registerColumnType(Types.SMALLINT, "smallint");
registerColumnType(Types.SMALLINT, "smallint");
registerColumnType(Types.TINYINT, "tinyint");
registerColumnType(Types.TINYINT, "tinyint");
registerColumnType(Types.TIME, "time");
registerColumnType(Types.TIME, "time");
...
@@ -47,7 +58,7 @@ public class H2Dialect extends Dialect {
...
@@ -47,7 +58,7 @@ public class H2Dialect extends Dialect {
registerColumnType(Types.NUMERIC, "numeric");
registerColumnType(Types.NUMERIC, "numeric");
registerColumnType(Types.BLOB, "blob");
registerColumnType(Types.BLOB, "blob");
registerColumnType(Types.CLOB, "clob");
registerColumnType(Types.CLOB, "clob");
// select topic, syntax from information_schema.help
// select topic, syntax from information_schema.help
// where section like 'Function%' order by section, topic
// where section like 'Function%' order by section, topic
...
@@ -121,7 +132,7 @@ public class H2Dialect extends Dialect {
...
@@ -121,7 +132,7 @@ public class H2Dialect extends Dialect {
registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
registerFunction("datediff", new
NoArg
SQLFunction("datediff", Hibernate.INTEGER));
registerFunction("datediff", new
Standard
SQLFunction("datediff", Hibernate.INTEGER));
registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
...
@@ -185,10 +196,10 @@ public class H2Dialect extends Dialect {
...
@@ -185,10 +196,10 @@ public class H2Dialect extends Dialect {
append(hasOffset ? " limit ? offset ?" : " limit ?").
append(hasOffset ? " limit ? offset ?" : " limit ?").
toString();
toString();
}
}
public boolean bindLimitParametersInReverseOrder() {
public boolean bindLimitParametersInReverseOrder() {
return true;
return true;
}
}
public boolean bindLimitParametersFirst() {
public boolean bindLimitParametersFirst() {
return false;
return false;
...
@@ -198,16 +209,20 @@ public class H2Dialect extends Dialect {
...
@@ -198,16 +209,20 @@ public class H2Dialect extends Dialect {
return true;
return true;
}
}
public String[] getCreateSequenceStrings(String sequenceName) {
public boolean supportsSequences() {
return new String[] {
return true;
"create sequence " + sequenceName
}
};
public boolean supportsPooledSequences() {
return true;
}
public String getCreateSequenceString(String sequenceName) {
return "create sequence " + sequenceName;
}
}
public String[] getDropSequenceStrings(String sequenceName) {
public String getDropSequenceString(String sequenceName) {
return new String[] {
return "drop sequence " + sequenceName;
"drop sequence " + sequenceName
};
}
}
public String getSelectSequenceNextValString(String sequenceName) {
public String getSelectSequenceNextValString(String sequenceName) {
...
@@ -222,11 +237,7 @@ public class H2Dialect extends Dialect {
...
@@ -222,11 +237,7 @@ public class H2Dialect extends Dialect {
return querySequenceString;
return querySequenceString;
}
}
public boolean supportsSequences() {
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return true;
}
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
return EXTRACTER;
}
}
...
@@ -235,15 +246,15 @@ public class H2Dialect extends Dialect {
...
@@ -235,15 +246,15 @@ public class H2Dialect extends Dialect {
/**
/**
* Extract the name of the violated constraint from the given SQLException.
* Extract the name of the violated constraint from the given SQLException.
*
*
* @param e The exception that was the result of the constraint violation.
* @param
sql
e The exception that was the result of the constraint violation.
* @return The extracted constraint name.
* @return The extracted constraint name.
*/
*/
public String extractConstraintName(SQLException e) {
public String extractConstraintName(SQLException
sql
e) {
String constraintName = null;
String constraintName = null;
// 23000: Check constraint violation: {0}
// 23000: Check constraint violation: {0}
// 23001: Unique index or primary key violation: {0}
// 23001: Unique index or primary key violation: {0}
if(e.getSQLState().startsWith("23")) {
if(
sql
e.getSQLState().startsWith("23")) {
String message = e.getMessage();
String message =
sql
e.getMessage();
int idx = message.indexOf("violation: ");
int idx = message.indexOf("violation: ");
if(idx > 0) {
if(idx > 0) {
constraintName = message.substring(idx + "violation: ".length());
constraintName = message.substring(idx + "violation: ".length());
...
@@ -257,7 +268,7 @@ public class H2Dialect extends Dialect {
...
@@ -257,7 +268,7 @@ public class H2Dialect extends Dialect {
public boolean supportsTemporaryTables() {
public boolean supportsTemporaryTables() {
return true;
return true;
}
}
public String getCreateTemporaryTableString() {
public String getCreateTemporaryTableString() {
return "create temporary table if not exists";
return "create temporary table if not exists";
}
}
...
@@ -265,17 +276,23 @@ public class H2Dialect extends Dialect {
...
@@ -265,17 +276,23 @@ public class H2Dialect extends Dialect {
public boolean supportsCurrentTimestampSelection() {
public boolean supportsCurrentTimestampSelection() {
return true;
return true;
}
}
public boolean isCurrentTimestampSelectStringCallable() {
public boolean isCurrentTimestampSelectStringCallable() {
return false;
return false;
}
}
public String getCurrentTimestampSelectString() {
public String getCurrentTimestampSelectString() {
return "call current_timestamp()";
return "call current_timestamp()";
}
}
public boolean supportsUnionAll() {
public boolean supportsUnionAll() {
return true;
return true;
}
}
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsLobValueChangePropogation() {
return false;
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论