timesTen 11.22版本 Hibernate方言
来源:互联网 发布:大数据时代小数据分析 编辑:程序博客网 时间:2024/05/02 00:40
package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.NvlFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.sql.ANSIJoinFragment;
import org.hibernate.sql.JoinFragment;
/**
* A SQL dialect for TimesTen version 11.2.2.x.x.
*
* This dialect is designed for use with TimesTen 11.2.2.x.x databases
* configured for Oracle type mode (TypeMode=0).
*
* Changes from previous versions:
*
* 1. CLOB, NCLOB and BLOB data types are now supported by TimesTen.
* 2. Added Oracle implementation of getBasicSelectClauseNullString() and
* getSelectClauseNullString().
* 3. Added support for the ADD_MONTHS(), MONTHS_BETWEEN(), SOUNDEX() and
* REPLACE () SQL functions.
*
* @author Jason Feldhaus (jason.feldhaus@oracle.com)
*/
public class TimesTenDialect1122
extends Dialect
{
public TimesTenDialect1122()
{
super();
// type mappings
registerColumnType(Types.BIT, "TT_TINYINT");
registerColumnType(Types.SMALLINT, "TT_SMALLINT");
registerColumnType(Types.TINYINT, "TT_TINYINT");
registerColumnType(Types.INTEGER, "TT_INTEGER");
registerColumnType(Types.BIGINT, "TT_BIGINT");
registerColumnType(Types.CHAR, "CHAR(1)");
registerColumnType(Types.VARCHAR, 4194304, "VARCHAR2($l)");
registerColumnType(Types.LONGVARCHAR, 4194304, "VARCHAR2($l)");
registerColumnType(Types.BINARY, 8300, "BINARY($l)" );
registerColumnType(Types.VARBINARY, 4194304, "VARBINARY($l)");
registerColumnType(Types.LONGVARBINARY, 4194304, "VARBINARY($l)");
registerColumnType(Types.NUMERIC, "NUMBER($p,$s)");
registerColumnType(Types.DECIMAL, "NUMBER($p,$s)" );
registerColumnType(Types.FLOAT, "BINARY_FLOAT");
registerColumnType(Types.DOUBLE, "BINARY_DOUBLE");
registerColumnType(Types.DATE, "TT_DATE");
registerColumnType(Types.TIME, "TT_TIME");
registerColumnType(Types.TIMESTAMP, "TIMESTAMP");
registerColumnType(Types.BLOB, "BLOB");
registerColumnType(Types.CLOB, "CLOB");
registerColumnType(Types.NCLOB, "NCLOB");
// properties
getDefaultProperties().setProperty(
Environment.USE_STREAMS_FOR_BINARY, "true");
getDefaultProperties().setProperty(
Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
// string functions
registerFunction("lower", new StandardSQLFunction("lower"));
registerFunction("upper", new StandardSQLFunction("upper"));
registerFunction("rtrim", new StandardSQLFunction("rtrim"));
registerFunction("ltrim", new StandardSQLFunction("ltrim") );
registerFunction("length",
new StandardSQLFunction("length", Hibernate.LONG) );
registerFunction( "concat",
new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
registerFunction("to_char",
new StandardSQLFunction("to_char", Hibernate.STRING));
registerFunction("chr",
new StandardSQLFunction("chr", Hibernate.CHARACTER));
registerFunction("instr",
new StandardSQLFunction("instr", Hibernate.INTEGER) );
registerFunction("instrb",
new StandardSQLFunction("instrb", Hibernate.INTEGER) );
registerFunction("lpad",
new StandardSQLFunction("lpad", Hibernate.STRING) );
registerFunction( "rpad",
new StandardSQLFunction("rpad", Hibernate.STRING) );
registerFunction("substr",
new StandardSQLFunction("substr", Hibernate.STRING) );
registerFunction("substrb",
new StandardSQLFunction("substrb", Hibernate.STRING) );
registerFunction("substring",
new StandardSQLFunction( "substr", Hibernate.STRING ) );
registerFunction("locate",
new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
registerFunction( "str",
new StandardSQLFunction("to_char", Hibernate.STRING) );
registerFunction( "soundex",
new StandardSQLFunction("soundex") );
registerFunction( "replace",
new StandardSQLFunction("replace", Hibernate.STRING) );
// date/time functions
registerFunction("to_date",
new StandardSQLFunction("to_date", Hibernate.TIMESTAMP));
registerFunction("sysdate",
new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false));
registerFunction("getdate",
new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false));
registerFunction("current_date",
new NoArgSQLFunction("sysdate", Hibernate.DATE, false));
registerFunction("current_time",
new NoArgSQLFunction("sysdate", Hibernate.TIME, false));
registerFunction("current_timestamp",
new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false));
// Multi-param date dialect functions...
registerFunction( "add_months",
new StandardSQLFunction("add_months", Hibernate.DATE) );
registerFunction( "months_between",
new StandardSQLFunction("months_between", Hibernate.FLOAT) );
// math functions
registerFunction("abs", new StandardSQLFunction("abs") );
registerFunction("sign",
new StandardSQLFunction("sign", Hibernate.INTEGER));
registerFunction("mod", new StandardSQLFunction("mod"));
registerFunction("round", new StandardSQLFunction("round"));
registerFunction("trunc", new StandardSQLFunction("trunc"));
registerFunction("ceil", new StandardSQLFunction("ceil"));
registerFunction("floor", new StandardSQLFunction("floor"));
registerFunction("power",
new StandardSQLFunction("power", Hibernate.FLOAT));
// misc. functions
registerFunction("nvl", new StandardSQLFunction("nvl"));
registerFunction("coalesce", new NvlFunction());
registerFunction( "user",
new NoArgSQLFunction("user", Hibernate.STRING, false) );
registerFunction( "rowid",
new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
registerFunction( "rownum",
new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
}
public boolean dropConstraints()
{
return true;
}
public boolean qualifyIndexName()
{
return false;
}
public boolean supportsUnique()
{
return true;
}
public boolean supportsUniqueConstraintInCreateAlterTable()
{
return false;
}
public String getAddColumnString()
{
return "add";
}
public boolean supportsSequences()
{
return true;
}
public boolean supportsPooledSequences()
{
return true;
}
public String getSelectSequenceNextValString(String sequenceName)
{
return sequenceName + ".nextval";
}
public String getSequenceNextValString(String sequenceName)
{
return "select " + sequenceName + ".nextval from sys.dual";
}
public String getCreateSequenceString(String sequenceName)
{
return "create sequence " + sequenceName;
}
public String getDropSequenceString(String sequenceName)
{
return "drop sequence " + sequenceName;
}
public String getQuerySequencesString()
{
return "select name from sys.sequences";
}
public JoinFragment createOuterJoinFragment()
{
// this dialect previously used OracleJoinFragment which resulted in
// various SQL errors - ANSIJoinFragment is more reliable
return new ANSIJoinFragment();
}
public String getForUpdateString()
{
return " for update";
}
public boolean supportsForUpdateNowait()
{
return true;
}
public String getForUpdateNowaitString()
{
return " for update nowait";
}
public boolean supportsColumnCheck()
{
return false;
}
public boolean supportsTableCheck()
{
return false;
}
public boolean supportsLimitOffset()
{
return true;
}
public boolean supportsVariableLimit()
{
// a limit string using literals instead of parameters is
// required to translate from Hibernate's 0 based row numbers
// to TimesTen 1 based row numbers
return false;
}
public boolean supportsLimit()
{
return true;
}
public boolean useMaxForLimit()
{
return true;
}
public boolean bindLimitParametersFirst()
{
return true;
}
public String getLimitString (String query, int offset, int limit)
{
// translate from Hibernate's 0 based row numbers to TimesTen's
// 1 based row numbers
String pagingClause = " rows " + (offset + 1) + " to " + limit;
// use the 'SELECT ROWS M to N' syntax
return new StringBuffer(query.length() + pagingClause.length()).
append(query).insert(6, pagingClause).toString();
}
public String getBasicSelectClauseNullString (int sqlType)
{
return super.getSelectClauseNullString (sqlType);
}
public String getSelectClauseNullString (int sqlType)
{
switch (sqlType)
{
case Types.VARCHAR:
case Types.CHAR:
return "to_char(null)";
case Types.DATE:
case Types.TIMESTAMP:
case Types.TIME:
return "to_date(null)";
default:
return "to_number(null)";
}
}
public boolean supportsCurrentTimestampSelection()
{
return true;
}
public String getCurrentTimestampSelectString()
{
return "select sysdate from sys.dual";
}
public boolean isCurrentTimestampSelectStringCallable()
{
return false;
}
public boolean supportsTemporaryTables()
{
return true;
}
public String generateTemporaryTableName(String baseTableName)
{
String name = super.generateTemporaryTableName(baseTableName);
return name.length() > 30? name.substring(1, 30): name;
}
public String getCreateTemporaryTableString()
{
return "create global temporary table";
}
public String getCreateTemporaryTablePostfix()
{
return "on commit delete rows";
}
public boolean supportsUnionAll()
{
return true;
}
public boolean supportsEmptyInList()
{
return true;
}
public boolean supportsCircularCascadeDeleteConstraints()
{
return false;
}
}
- timesTen 11.22版本 Hibernate方言
- mysql版本导致的hibernate 方言问题
- hibernate 方言
- hibernate 方言
- hibernate方言
- 不同MySql版本问题需要的Hibernate 方言问题
- hibernate 的SQL方言
- Hibernate SQL方言
- Hibernate SQL方言收藏
- Hibernate数据库方言
- 获取hibernate方言
- Hibernate方言总结
- Hibernate方言(全)
- hibernate支持的方言
- hibernate 数据库方言列表
- Hibernate配置数据库方言
- Hibernate SQL 方言
- hibernate sql方言
- oracle wm_concat函数的使用
- 相约世纪末
- 给自己的网站 地址栏加自定义图标
- ASP.net中aspx与cs函数的互调,知道这个很必要。
- oracle sqlplus基本操作
- timesTen 11.22版本 Hibernate方言
- MVC 3.0 使用筛选器
- 要内心强大,做个美好温暖自立自强的女子
- 狗语翻译器热销?神马玩意
- 使用工具将中文转化成ascii编码
- 图像处理基本算法-直方图均衡
- 信息图:第一印象的魅力
- 使用aws邮件服务
- SQL中Exists用法