8000 4.1.6版本 · coder-zhw/Mybatis-PageHelper@05b91a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05b91a9

Browse files
committed
4.1.6版本
通过间接处理字符串解决SqlServer中不支持`with(nolock)`的问题pagehelper#86,详情可以看`SqlServerParser`和`SqlServer2012Dialect`
1 parent 0b363a5 commit 05b91a9

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636

3737
##分页插件支持MyBatis3.2.0~3.3.0(包含)
3838

39-
##分页插件最新版本为4.1.5
39+
##分页插件最新版本为4.1.6
4040

4141
###Maven坐标
4242

4343
```xml
4444
<dependency>
4545
<groupId>com.github.pagehelper</groupId>
4646
<artifactId>pagehelper</artifactId>
47-
<version>4.1.5</version>
47+
<version>4.1.6</version>
4848
</dependency>
4949
```
5050

@@ -66,6 +66,10 @@
6666

6767
- http://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/0.9.1/
6868

69+
##4.1.6更新日志
70+
71+
- 通过间接处理字符串解决SqlServer中不支持`with(nolock)`的问题#86,详情可以看`SqlServerParser``SqlServer2012Dialect`
72+
6973
##4.1.5更新日志
7074

7175
- 更新`PageProviderSqlSource`,支持3.4.0版本的`Provider`注解方式的分页#102

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<groupId>com.github.pagehelper</groupId>
3030
<artifactId>pagehelper</artifactId>
31-
<version>4.1.5</version>
31+
<version>4.1.6</version>
3232
<packaging>jar</packaging>
3333

3434
<name>pagehelper</name>

src/main/java/com/github/pagehelper/parser/impl/SqlServer2012Dialect.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
* in oder for OFFSET .. ROWS to work
1313
*/
1414
public class SqlServer2012Dialect extends AbstractParser {
15+
//with(nolock)
16+
protected static final String WITHNOLOCK = ", PAGEWITHNOLOCK";
17+
18+
@Override
19+
public String getCountSql(String sql) {
20+
sql = sql.replaceAll("((?i)with\\s*\\(nolock\\))", WITHNOLOCK);
21+
sql = super.getCountSql(sql);
22+
sql = sql.replace(WITHNOLOCK, " with(nolock)");
23+
return sql;
24+
}
1525

1626
@Override
1727
public String getPageSql(String sql) {

src/main/java/com/github/pagehelper/parser/impl/SqlServerParser.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
public class SqlServerParser extends AbstractParser {
4242
private static final SqlServer pageSql = new SqlServer();
4343

44+
//with(nolock)
45+
protected static final String WITHNOLOCK = ", PAGEWITHNOLOCK";
46+
47+
@Override
48+
public String getCountSql(String sql) {
49+
sql = sql.replaceAll("((?i)with\\s*\\(nolock\\))", WITHNOLOCK);
50+
sql = super.getCountSql(sql);
51+
sql = sql.replace(WITHNOLOCK, " with(nolock)");
52+
return sql;
53+
}
54+
4455
@Override
4556
public boolean isSupportedMappedStatementCache() {
4657
//由于sqlserver每次分页参数都是直接写入到sql语句中,因此不能缓存MS
@@ -55,7 +66,10 @@ public List<ParameterMapping> getPageParameterMapping(Configuration configuratio
5566
@Override
5667
public String getPageSql(String sql) {
5768
Page<?> page = SqlUtil.getLocalPage();
58-
return pageSql.convertToPageSql(sql, page.getStartRow(), page.getPageSize());
69+
sql = sql.replaceAll("((?i)with\\s*\\(nolock\\))", WITHNOLOCK);
70+
sql = pageSql.convertToPageSql(sql, page.getStartRow(), page.getPageSize());
71+
sql = sql.replace(WITHNOLOCK, " with(nolock)");
72+
return sql;
5973
}
6074

6175
@Override

wikis/Changelog.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
##更新日志
22

3-
##4.1.5 - 2016-05-29
3+
##4.1.6 - 2016-06-05
4+
5+
- 通过间接处理字符串解决SqlServer中不支持`with(nolock)`的问题#86,详情可以看`SqlServerParser``SqlServer2012Dialect`
6+
7+
###4.1.5 - 2016-05-29
48

59
- 更新`PageProviderSqlSource`,支持3.4.0版本的`Provider`注解方式的分页#102
610
- 解决`SqlUtil`未初始化`PARAMS`属性导致的错误

wikis/HowToUse.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.github.pagehelper</groupId>
2828
<artifactId>pagehelper</artifactId>
29-
<version>4.1.5</version>
29+
<version>4.1.6</version>
3030
</dependency>
3131
```
3232

0 commit comments

Comments
 (0)
0