1、DB2Dialect方法
public String getLimitString(String sql, boolean hasOffset) {
int startOfSelect = sql.toLowerCase().indexOf("select");
StringBuffer pagingSelect = new StringBuffer(sql.length() + 100)
.append(sql.substring(0, startOfSelect)) // add the comment
.append("select * from ( select ") // nest the main query in an
.append(getRowNumber(sql)); // add the rownnumber bit into the
int orderByIndex = sql.toLowerCase().indexOf("order by");
if (hasDistinct(sql)) {
pagingSelect.append(" row_.* from ( ");
if (orderByIndex > 0) // whithout ordey by
pagingSelect.append(sql.substring(startOfSelect, orderByIndex));
else
pagingSelect.append(sql.substring(startOfSelect));
pagingSelect.append(" ) as row_"); // close off the inner nested
// select
} else {
if (orderByIndex > 0) // whithout ordey by
pagingSelect.append(sql.substring(startOfSelect + 6,
orderByIndex));
else
pagingSelect.append(sql.substring(startOfSelect + 6));
}
pagingSelect.append(" ) as temp_ where rownumber_ ");
// add the restriction to the outer select
if (hasOffset) {
pagingSelect.append("between ?+1 and ?");
} else {
pagingSelect.append("<= ?");
}
return pagingSelect.toString();
}
输出的sql语句:
select * from( select rownumber() over(order by nocardtran0_.id desc) as rownumber_,
nocardtran0_.id as id13_,
nocardtran0_.account_number1 as account2_13_,
nocardtran0_.account_number2 as account3_13_,
nocardtran0_.acq_id as acq4_13_,
nocardtran0_.acq_inst_resvd as acq5_13_,
nocardtran0_.auth_resp_code as auth6_13_,
nocardtran0_.cell_phone as cell7_13_,
nocardtran0_.cert_info as cert8_13_,
nocardtran0_.content_provider_id as content9_13_,
nocardtran0_.create_time as create10_13_,
nocardtran0_.imei as imei13_,
nocardtran0_.mcc as mcc13_,
nocardtran0_.merchant_country as merchant13_13_,
nocardtran0_.merchant_id as merchant14_13_,
nocardtran0_.merchant_name as merchant15_13_,
nocardtran0_.merchant_type_code as merchant16_13_,
nocardtran0_.mobile_type as mobile17_13_,
nocardtran0_.order_generate_time as order18_13_,
nocardtran0_.order_id as order19_13_,
nocardtran0_.order_info as order20_13_,
nocardtran0_.order_type as order21_13_,
nocardtran0_.orig_submit_time as orig22_13_,
nocardtran0_.orig_trans_serial as orig23_13_,
nocardtran0_.os_info as os24_13_,
nocardtran0_.resp_code as resp25_13_,
nocardtran0_.retrvl_ref_no as retrvl26_13_,
nocardtran0_.service_info as service27_13_,
nocardtran0_.session_id as session28_13_,
nocardtran0_.settle_date as settle29_13_,
nocardtran0_.submit_time as submit30_13_,
nocardtran0_.system_provider_id as system31_13_,
nocardtran0_.terminal_id as terminal32_13_,
nocardtran0_.trans_amount as trans33_13_,
nocardtran0_.trans_currency as trans34_13_,
nocardtran0_.trans_serial as trans35_13_,
nocardtran0_.transmit_time as transmit36_13_,
nocardtran0_.user_dev_id as user37_13_
from
MP_ONLDB.tbl_nocard_trans_info_process nocardtran0_
order by
nocardtran0_.id desc ) as temp_
where
rownumber_ between ?+1 and ?
2、DB2400Dialect方法
public String getLimitString(String sql, int offset, int limit) {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( sql.length() + 40 )
.append( sql )
.append( " fetch first " )
.append( limit )
.append( " rows only " )
.toString();
}
输出的sql语句:
fetch first ? rows
网上有人说使用DB2Dialect方式性能比DB2400Dialect好,参考
http://www.blogjava.net/kelefa/archive/2007/08/27/90246.html,可我测试时却发现
使用DB2Dialect情况下CPU使用率一直会冲高,先记录个草稿,有时间再研究一下。
分享到:
相关推荐
在MySQL中,MyBatis-SQL-Dialect会处理如`LIMIT`和`ORDER BY`等特有的语法,以及提供对MySQL特定函数的调用,如`DATE_FORMAT`用于格式化日期。这使得开发者在使用MyBatis时,可以编写更符合MySQL习惯的SQL语句。 4...
DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect PostgreSQL org.hibernate.dialect.PostgreSQLDialect MySQL ...
* DB2:org.hibernate.dialect.DB2Dialect * DB2 AS/400:org.hibernate.dialect.DB2400Dialect * DB2 OS390:org.hibernate.dialect.DB2390Dialect * PostgreSQL:org.hibernate.dialect.PostgreSQLDialect * MySQL...
MYSQL常用命令 和SQL语句(方言dialect)
- **DB2 AS/400 Dialect**:专门针对IBM DB2 for AS/400系统设计。 - **DB2 OS/390 Dialect**:为IBM DB2 for OS/390环境优化。 #### PostgreSQL - **PostgreSQL Dialect**:用于PostgreSQL数据库,这是一个功能...
hibernate3.6.0dialect.jar
这个jar包包含了达梦数据库特有的SQL转换规则和函数实现,使得开发人员可以无缝地在Java应用中连接和操作达梦数据库。 【如何使用达梦dialect方言jar包】 1. **集成到项目**:首先,将这个jar包添加到你的Java项目...
"Laravel开发-dialect"很可能是一个专门为Eloquent ORM扩展的项目,旨在增强其对JSON数据类型的处理能力,特别是在MySQL和PostgreSQL等支持JSON数据类型的数据库中。 在现代Web应用中,JSON数据类型变得越来越重要...
SQLServer2008Dialect 优化了原来的分页查询数据方法以及在生成SQL时表后增加了with(nolock)
"DM达梦数据库jdbc-jar包dialect方言jar包"就是包含了针对达梦数据库的方言实现,它使得这些框架可以正确处理DM达梦数据库特有的SQL语法和存储过程,从而提高代码的可移植性和兼容性。 在使用DM达梦数据库jdbc-jar...
hibernate 4以上Hibernate.INTEGER之类的不能使用了,之前使用的SQLiteDialect.java编译不过去了,这个可以。
SQLServer2008Dialect 优化了原来的分页查询数据方法以及在生成SQL时表后增加了with(nolock)
达梦数据库方言 (dialect) jar包 包含hibernate各版本,DmHibernateSpatial-1.0.jar, DmHibernateSpatial-1.1.jar,DmDialect-for-hibernate5.3.jar ... DmDictionary.jar,dmjooq-dialect-3.12.3.jar,gt-dameng-...
- **通用DB2**:`org.hibernate.dialect.DB2Dialect`用于所有版本的DB2数据库。 - **DB2 AS/400**:`org.hibernate.dialect.DB2400Dialect`专门针对运行在AS/400平台上的DB2数据库。 - **DB2 OS/390**:`org....
南大通用GBase数据库GBase_Hibernate3.2.3_GA-Dialect_8.3.81.51_build50.1.jar
hibernate3dialect
我的sqlite dialect.java
- DB2Dialect:适用于标准的DB2数据库。 - DB2400Dialect:针对AS/400平台的DB2。 - DB2390Dialect:用于OS390环境的DB2。 2. **PostgreSQL方言**: - PostgreSQLDialect:适用于PostgreSQL数据库。 3. **...
hibernate下的kingbase的jar文件,需要的同学自行下载