HHH-6577 code style format
This commit is contained in:
parent
d2045611aa
commit
8ee4156a1a
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||||
* indicated by the @author tags or express copyright attribution
|
* indicated by the @author tags or express copyright attribution
|
||||||
* statements applied by the authors. All third-party contributions are
|
* statements applied by the authors. All third-party contributions are
|
||||||
* distributed under license by Red Hat Inc.
|
* distributed under license by Red Hat Inc.
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
@ -31,210 +32,188 @@ import org.hibernate.dialect.function.NoArgSQLFunction;
|
||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||||
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
import org.hibernate.dialect.function.VarArgsSQLFunction;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for CUBRID (8.3.x and later).
|
* An SQL dialect for CUBRID (8.3.x and later).
|
||||||
*
|
*
|
||||||
* @author Seok Jeong Il
|
* @author Seok Jeong Il
|
||||||
*/
|
*/
|
||||||
public class CUBRIDDialect extends Dialect
|
public class CUBRIDDialect extends Dialect {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected String getIdentityColumnString() throws MappingException
|
protected String getIdentityColumnString() throws MappingException {
|
||||||
{
|
|
||||||
return "auto_increment"; //starts with 1, implicitly
|
return "auto_increment"; //starts with 1, implicitly
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentitySelectString(String table, String column, int type)
|
public String getIdentitySelectString(String table, String column, int type)
|
||||||
throws MappingException
|
throws MappingException {
|
||||||
{
|
|
||||||
// CUBRID 8.4.0 support last_insert_id()
|
// CUBRID 8.4.0 support last_insert_id()
|
||||||
// return "select last_insert_id()";
|
// return "select last_insert_id()";
|
||||||
return "select current_val from db_serial where name = '" + (table + "_ai_" + column).toLowerCase() + "'";
|
return "select current_val from db_serial where name = '" + ( table + "_ai_" + column ).toLowerCase() + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CUBRIDDialect()
|
public CUBRIDDialect() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
registerColumnType(Types.BIT, "bit(8)" );
|
registerColumnType( Types.BIT, "bit(8)" );
|
||||||
registerColumnType(Types.BIGINT, "numeric(19,0)" );
|
registerColumnType( Types.BIGINT, "numeric(19,0)" );
|
||||||
registerColumnType(Types.SMALLINT, "short" );
|
registerColumnType( Types.SMALLINT, "short" );
|
||||||
registerColumnType(Types.TINYINT, "short" );
|
registerColumnType( Types.TINYINT, "short" );
|
||||||
registerColumnType(Types.INTEGER, "integer" );
|
registerColumnType( Types.INTEGER, "integer" );
|
||||||
registerColumnType(Types.CHAR, "char(1)" );
|
registerColumnType( Types.CHAR, "char(1)" );
|
||||||
registerColumnType(Types.VARCHAR, 4000, "varchar($l)" );
|
registerColumnType( Types.VARCHAR, 4000, "varchar($l)" );
|
||||||
registerColumnType(Types.FLOAT, "float" );
|
registerColumnType( Types.FLOAT, "float" );
|
||||||
registerColumnType(Types.DOUBLE, "double" );
|
registerColumnType( Types.DOUBLE, "double" );
|
||||||
registerColumnType(Types.DATE, "date" );
|
registerColumnType( Types.DATE, "date" );
|
||||||
registerColumnType(Types.TIME, "time" );
|
registerColumnType( Types.TIME, "time" );
|
||||||
registerColumnType(Types.TIMESTAMP, "timestamp" );
|
registerColumnType( Types.TIMESTAMP, "timestamp" );
|
||||||
registerColumnType(Types.VARBINARY, 2000,"bit varying($l)");
|
registerColumnType( Types.VARBINARY, 2000, "bit varying($l)" );
|
||||||
registerColumnType(Types.NUMERIC, "numeric($p,$s)" );
|
registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
|
||||||
registerColumnType(Types.BLOB, "blob" );
|
registerColumnType( Types.BLOB, "blob" );
|
||||||
registerColumnType(Types.CLOB, "string" );
|
registerColumnType( Types.CLOB, "string" );
|
||||||
|
|
||||||
getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
|
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
|
||||||
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
|
|
||||||
registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
|
registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("trim", new StandardSQLFunction("trim") );
|
registerFunction( "trim", new StandardSQLFunction( "trim" ) );
|
||||||
registerFunction("length", new StandardSQLFunction("length", StandardBasicTypes.INTEGER) );
|
registerFunction( "length", new StandardSQLFunction( "length", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("bit_length",new StandardSQLFunction("bit_length", StandardBasicTypes.INTEGER) );
|
registerFunction( "bit_length", new StandardSQLFunction( "bit_length", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("coalesce", new StandardSQLFunction("coalesce") );
|
registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
|
||||||
registerFunction("nullif", new StandardSQLFunction("nullif") );
|
registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
|
||||||
registerFunction("abs", new StandardSQLFunction("abs") );
|
registerFunction( "abs", new StandardSQLFunction( "abs" ) );
|
||||||
registerFunction("mod", new StandardSQLFunction("mod") );
|
registerFunction( "mod", new StandardSQLFunction( "mod" ) );
|
||||||
registerFunction("upper", new StandardSQLFunction("upper") );
|
registerFunction( "upper", new StandardSQLFunction( "upper" ) );
|
||||||
registerFunction("lower", new StandardSQLFunction("lower") );
|
registerFunction( "lower", new StandardSQLFunction( "lower" ) );
|
||||||
|
|
||||||
registerFunction("power", new StandardSQLFunction("power") );
|
registerFunction( "power", new StandardSQLFunction( "power" ) );
|
||||||
registerFunction("stddev", new StandardSQLFunction("stddev") );
|
registerFunction( "stddev", new StandardSQLFunction( "stddev" ) );
|
||||||
registerFunction("variance", new StandardSQLFunction("variance") );
|
registerFunction( "variance", new StandardSQLFunction( "variance" ) );
|
||||||
registerFunction("round", new StandardSQLFunction("round") );
|
registerFunction( "round", new StandardSQLFunction( "round" ) );
|
||||||
registerFunction("trunc", new StandardSQLFunction("trunc") );
|
registerFunction( "trunc", new StandardSQLFunction( "trunc" ) );
|
||||||
registerFunction("ceil", new StandardSQLFunction("ceil") );
|
registerFunction( "ceil", new StandardSQLFunction( "ceil" ) );
|
||||||
registerFunction("floor", new StandardSQLFunction("floor") );
|
registerFunction( "floor", new StandardSQLFunction( "floor" ) );
|
||||||
registerFunction("ltrim", new StandardSQLFunction("ltrim") );
|
registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
|
||||||
registerFunction("rtrim", new StandardSQLFunction("rtrim") );
|
registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
|
||||||
registerFunction("nvl", new StandardSQLFunction("nvl") );
|
registerFunction( "nvl", new StandardSQLFunction( "nvl" ) );
|
||||||
registerFunction("nvl2", new StandardSQLFunction("nvl2") );
|
registerFunction( "nvl2", new StandardSQLFunction( "nvl2" ) );
|
||||||
registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) );
|
registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER));
|
registerFunction( "chr", new StandardSQLFunction( "chr", StandardBasicTypes.CHARACTER ) );
|
||||||
registerFunction("to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) );
|
registerFunction( "to_char", new StandardSQLFunction( "to_char", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP));
|
registerFunction( "to_date", new StandardSQLFunction( "to_date", StandardBasicTypes.TIMESTAMP ) );
|
||||||
registerFunction("last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE) );
|
registerFunction( "last_day", new StandardSQLFunction( "last_day", StandardBasicTypes.DATE ) );
|
||||||
registerFunction("instr", new StandardSQLFunction("instr", StandardBasicTypes.INTEGER) );
|
registerFunction( "instr", new StandardSQLFunction( "instr", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("instrb", new StandardSQLFunction("instrb", StandardBasicTypes.INTEGER) );
|
registerFunction( "instrb", new StandardSQLFunction( "instrb", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("lpad", new StandardSQLFunction("lpad", StandardBasicTypes.STRING) );
|
registerFunction( "lpad", new StandardSQLFunction( "lpad", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("replace", new StandardSQLFunction("replace", StandardBasicTypes.STRING) );
|
registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("rpad", new StandardSQLFunction("rpad", StandardBasicTypes.STRING) );
|
registerFunction( "rpad", new StandardSQLFunction( "rpad", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
|
registerFunction( "substr", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("substrb", new StandardSQLFunction("substrb", StandardBasicTypes.STRING) );
|
registerFunction( "substrb", new StandardSQLFunction( "substrb", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("translate", new StandardSQLFunction("translate", StandardBasicTypes.STRING) );
|
registerFunction( "translate", new StandardSQLFunction( "translate", StandardBasicTypes.STRING ) );
|
||||||
registerFunction("add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE) );
|
registerFunction( "add_months", new StandardSQLFunction( "add_months", StandardBasicTypes.DATE ) );
|
||||||
registerFunction("months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT) );
|
registerFunction( "months_between", new StandardSQLFunction( "months_between", StandardBasicTypes.FLOAT ) );
|
||||||
|
|
||||||
registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false) );
|
registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE, false ) );
|
||||||
registerFunction("current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false) );
|
registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME, false ) );
|
||||||
registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP,false) );
|
registerFunction(
|
||||||
registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.DATE, false) );
|
"current_timestamp",
|
||||||
registerFunction("systime", new NoArgSQLFunction("systime", StandardBasicTypes.TIME, false) );
|
new NoArgSQLFunction( "current_timestamp", StandardBasicTypes.TIMESTAMP, false )
|
||||||
registerFunction("systimestamp", new NoArgSQLFunction("systimestamp", StandardBasicTypes.TIMESTAMP,false) );
|
);
|
||||||
registerFunction("user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false) );
|
registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.DATE, false ) );
|
||||||
registerFunction("rownum", new NoArgSQLFunction("rownum", StandardBasicTypes.LONG, false) );
|
registerFunction( "systime", new NoArgSQLFunction( "systime", StandardBasicTypes.TIME, false ) );
|
||||||
registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
|
registerFunction( "systimestamp", new NoArgSQLFunction( "systimestamp", StandardBasicTypes.TIMESTAMP, false ) );
|
||||||
|
registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING, false ) );
|
||||||
|
registerFunction( "rownum", new NoArgSQLFunction( "rownum", StandardBasicTypes.LONG, false ) );
|
||||||
|
registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "", "||", "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddColumnString()
|
public String getAddColumnString() {
|
||||||
{
|
|
||||||
return "add";
|
return "add";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSequenceNextValString(String sequenceName)
|
public String getSequenceNextValString(String sequenceName) {
|
||||||
{
|
|
||||||
return "select " + sequenceName + ".next_value from table({1}) as T(X)";
|
return "select " + sequenceName + ".next_value from table({1}) as T(X)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreateSequenceString(String sequenceName)
|
public String getCreateSequenceString(String sequenceName) {
|
||||||
{
|
|
||||||
return "create serial " + sequenceName;
|
return "create serial " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDropSequenceString(String sequenceName)
|
public String getDropSequenceString(String sequenceName) {
|
||||||
{
|
|
||||||
return "drop serial " + sequenceName;
|
return "drop serial " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsSequences()
|
public boolean supportsSequences() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getQuerySequencesString()
|
public String getQuerySequencesString() {
|
||||||
{
|
|
||||||
return "select name from db_serial";
|
return "select name from db_serial";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dropConstraints()
|
public boolean dropConstraints() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsLimit()
|
public boolean supportsLimit() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLimitString(String sql, boolean hasOffset)
|
public String getLimitString(String sql, boolean hasOffset) {
|
||||||
{
|
|
||||||
// CUBRID 8.3.0 support limit
|
// CUBRID 8.3.0 support limit
|
||||||
return new StringBuffer(sql.length() + 20).append(sql)
|
return new StringBuffer( sql.length() + 20 ).append( sql )
|
||||||
.append(hasOffset ? " limit ?, ?" : " limit ?").toString();
|
.append( hasOffset ? " limit ?, ?" : " limit ?" ).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean bindLimitParametersInReverseOrder()
|
public boolean bindLimitParametersInReverseOrder() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useMaxForLimit()
|
public boolean useMaxForLimit() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forUpdateOfColumns()
|
public boolean forUpdateOfColumns() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public char closeQuote()
|
public char closeQuote() {
|
||||||
{
|
|
||||||
return ']';
|
return ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
public char openQuote()
|
public char openQuote() {
|
||||||
{
|
|
||||||
return '[';
|
return '[';
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAlterTable()
|
public boolean hasAlterTable() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getForUpdateString()
|
public String getForUpdateString() {
|
||||||
{
|
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsUnionAll()
|
public boolean supportsUnionAll() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsCommentOn()
|
public boolean supportsCommentOn() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsTemporaryTables()
|
public boolean supportsTemporaryTables() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsCurrentTimestampSelection()
|
public boolean supportsCurrentTimestampSelection() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentTimestampSelectString()
|
public String getCurrentTimestampSelectString() {
|
||||||
{
|
|
||||||
return "select systimestamp from table({1}) as T(X)";
|
return "select systimestamp from table({1}) as T(X)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCurrentTimestampSelectStringCallable()
|
public boolean isCurrentTimestampSelectStringCallable() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue