提交 c7e9dcc9 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 07236a50
...@@ -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>
......
...@@ -21,15 +21,26 @@ import org.hibernate.util.ReflectHelper; ...@@ -21,15 +21,26 @@ import org.hibernate.util.ReflectHelper;
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, "varchar($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");
...@@ -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 NoArgSQLFunction("datediff", Hibernate.INTEGER)); registerFunction("datediff", new StandardSQLFunction("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));
...@@ -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 String[] getDropSequenceStrings(String sequenceName) { public boolean supportsPooledSequences() {
return new String[] { return true;
"drop sequence " + sequenceName }
};
public String getCreateSequenceString(String sequenceName) {
return "create sequence " + sequenceName;
}
public String getDropSequenceString(String sequenceName) {
return "drop sequence " + sequenceName;
} }
public String getSelectSequenceNextValString(String sequenceName) { public String getSelectSequenceNextValString(String sequenceName) {
...@@ -222,10 +237,6 @@ public class H2Dialect extends Dialect { ...@@ -222,10 +237,6 @@ public class H2Dialect extends Dialect {
return querySequenceString; return querySequenceString;
} }
public boolean supportsSequences() {
return true;
}
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() { 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 sqle 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 sqle) {
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(sqle.getSQLState().startsWith("23")) {
String message = e.getMessage(); String message = sqle.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());
...@@ -278,4 +289,10 @@ public class H2Dialect extends Dialect { ...@@ -278,4 +289,10 @@ public class H2Dialect extends Dialect {
return true; return true;
} }
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean supportsLobValueChangePropogation() {
return false;
}
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论