提交 9c3816f0 authored 作者: Thomas Mueller's avatar Thomas Mueller

small improvements

上级 c9400ca5
...@@ -21,16 +21,14 @@ ...@@ -21,16 +21,14 @@
// Copyright (c) 1998, 2006, Oracle. All rights reserved. // Copyright (c) 1998, 2006, Oracle. All rights reserved.
package oracle.toplink.essentials.platform.database; package oracle.toplink.essentials.platform.database;
import java.util.*; import java.io.IOException;
import java.io.*; import java.io.Writer;
import java.sql.*; import java.util.Hashtable;
import oracle.toplink.essentials.exceptions.*;
import oracle.toplink.essentials.queryframework.*; import oracle.toplink.essentials.exceptions.ValidationException;
import oracle.toplink.essentials.internal.helper.*; import oracle.toplink.essentials.expressions.ExpressionOperator;
import oracle.toplink.essentials.expressions.*; import oracle.toplink.essentials.internal.databaseaccess.FieldTypeDefinition;
import oracle.toplink.essentials.internal.expressions.*; import oracle.toplink.essentials.queryframework.ValueReadQuery;
import oracle.toplink.essentials.internal.databaseaccess.*;
import oracle.toplink.essentials.internal.sessions.AbstractSession;
/** /**
* This platform provides H2 specific behaviour. * This platform provides H2 specific behaviour.
...@@ -48,12 +46,9 @@ import oracle.toplink.essentials.internal.sessions.AbstractSession; ...@@ -48,12 +46,9 @@ import oracle.toplink.essentials.internal.sessions.AbstractSession;
* @author Marcio Borges (http://www.marciowb.net/blog/2008_08_01_) * @author Marcio Borges (http://www.marciowb.net/blog/2008_08_01_)
*/ */
public class H2Platform extends DatabasePlatform { public class H2Platform extends DatabasePlatform {
public H2Platform() {
}
protected Hashtable buildFieldTypes() { protected Hashtable buildFieldTypes() {
Hashtable fieldTypeMapping; Hashtable fieldTypeMapping;
fieldTypeMapping = super.buildFieldTypes(); fieldTypeMapping = super.buildFieldTypes();
fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("TINYINT", false)); fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("TINYINT", false));
fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("INTEGER", false)); fieldTypeMapping.put(Integer.class, new FieldTypeDefinition("INTEGER", false));
...@@ -74,15 +69,9 @@ public class H2Platform extends DatabasePlatform { ...@@ -74,15 +69,9 @@ public class H2Platform extends DatabasePlatform {
fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE", false)); fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE", false));
fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("TIME", false)); fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("TIME", false));
fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMP", false)); fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMP", false));
return fieldTypeMapping; return fieldTypeMapping;
} }
// public boolean isHSQL() {
// return true;
// }
public boolean isH2() { public boolean isH2() {
return true; return true;
} }
...@@ -100,8 +89,6 @@ public class H2Platform extends DatabasePlatform { ...@@ -100,8 +89,6 @@ public class H2Platform extends DatabasePlatform {
buff.append(")"); buff.append(")");
String sql = buff.toString(); String sql = buff.toString();
return new ValueReadQuery(sql); return new ValueReadQuery(sql);
// return new ValueReadQuery("CALL NEXT VALUE FOR " + getQualifiedSequenceName(seqName));
// return new ValueReadQuery("SELECT " + getQualifiedSequenceName(seqName) + ".NEXTVAL FROM DUAL");
} }
public boolean supportsNativeSequenceNumbers() { public boolean supportsNativeSequenceNumbers() {
...@@ -111,9 +98,8 @@ public class H2Platform extends DatabasePlatform { ...@@ -111,9 +98,8 @@ public class H2Platform extends DatabasePlatform {
protected String getQualifiedSequenceName(String seqName) { protected String getQualifiedSequenceName(String seqName) {
if (getTableQualifier().equals("")) { if (getTableQualifier().equals("")) {
return seqName; return seqName;
} else {
return getTableQualifier() + "." + seqName;
} }
return getTableQualifier() + "." + seqName;
} }
public boolean supportsSelectForUpdateNoWait() { public boolean supportsSelectForUpdateNoWait() {
...@@ -140,5 +126,13 @@ public class H2Platform extends DatabasePlatform { ...@@ -140,5 +126,13 @@ public class H2Platform extends DatabasePlatform {
public ValueReadQuery buildSelectQueryForIdentity() { public ValueReadQuery buildSelectQueryForIdentity() {
return new ValueReadQuery("SELECT IDENTITY()"); return new ValueReadQuery("SELECT IDENTITY()");
} }
public void printFieldIdentityClause(Writer writer) throws ValidationException {
try {
writer.write(" IDENTITY");
} catch (final IOException ioException) {
throw ValidationException.fileError(ioException);
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论