Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
Mybatis Jpa Extra
提交
2a46b084
M
Mybatis Jpa Extra
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
Mybatis Jpa Extra
8 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mybatis Jpa Extra
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2a46b084
编写于
12月 06, 2019
作者:
MaxKey单点登录官方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GA
上级
d6651d03
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
149 addition
and
115 deletion
+149
-115
mybatis-jpa-extra-1.0.jar
mybatis-jpa-extra-1.0.jar
+0
-0
mybatis-jpa-extra-2.1-api-1.0.jar
mybatis-jpa-extra-2.1-api-1.0.jar
+0
-0
mybatis-jpa-extra-2.1-api/.classpath
mybatis-jpa-extra-2.1-api/.classpath
+1
-1
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/SpringBootVFS.java
...e/src/main/java/org/apache/mybatis/jpa/SpringBootVFS.java
+53
-0
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/DB2Dialect.java
.../main/java/org/apache/mybatis/jpa/dialect/DB2Dialect.java
+9
-9
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/DerbyDialect.java
...ain/java/org/apache/mybatis/jpa/dialect/DerbyDialect.java
+8
-8
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/MySQLDialect.java
...ain/java/org/apache/mybatis/jpa/dialect/MySQLDialect.java
+12
-12
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/OracleDialect.java
...in/java/org/apache/mybatis/jpa/dialect/OracleDialect.java
+8
-8
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/PostgreSQLDialect.java
...ava/org/apache/mybatis/jpa/dialect/PostgreSQLDialect.java
+11
-11
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/SQLServerDialect.java
...java/org/apache/mybatis/jpa/dialect/SQLServerDialect.java
+9
-9
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaBaseService.java
...va/org/apache/mybatis/jpa/persistence/JpaBaseService.java
+9
-9
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaPagination.java
...ava/org/apache/mybatis/jpa/persistence/JpaPagination.java
+25
-25
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
...t/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
+4
-4
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
...t/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
+0
-19
未找到文件。
mybatis-jpa-extra-1.0.jar
0 → 100644
浏览文件 @
2a46b084
文件已添加
mybatis-jpa-extra-2.1-api-1.0.jar
0 → 100644
浏览文件 @
2a46b084
文件已添加
mybatis-jpa-extra-2.1-api/.classpath
浏览文件 @
2a46b084
...
...
@@ -13,7 +13,7 @@
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER
/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8
"
>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/SpringBootVFS.java
0 → 100644
浏览文件 @
2a46b084
package
org.apache.mybatis.jpa
;
import
java.io.IOException
;
import
java.io.UncheckedIOException
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
org.apache.ibatis.io.VFS
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
/**
* @author Hans Westerbeek
* @author Eddú Meléndez
* @author Kazuki Shimizu
*/
public
class
SpringBootVFS
extends
VFS
{
private
final
ResourcePatternResolver
resourceResolver
;
public
SpringBootVFS
()
{
this
.
resourceResolver
=
new
PathMatchingResourcePatternResolver
(
getClass
().
getClassLoader
());
}
@Override
public
boolean
isValid
()
{
return
true
;
}
@Override
protected
List
<
String
>
list
(
URL
url
,
String
path
)
throws
IOException
{
String
urlString
=
url
.
toString
();
String
baseUrlString
=
urlString
.
endsWith
(
"/"
)
?
urlString
:
urlString
.
concat
(
"/"
);
Resource
[]
resources
=
resourceResolver
.
getResources
(
baseUrlString
+
"**/*.class"
);
return
Stream
.
of
(
resources
).
map
(
resource
->
preserveSubpackageName
(
baseUrlString
,
resource
,
path
))
.
collect
(
Collectors
.
toList
());
}
private
static
String
preserveSubpackageName
(
final
String
baseUrlString
,
final
Resource
resource
,
final
String
rootPath
)
{
try
{
return
rootPath
+
(
rootPath
.
endsWith
(
"/"
)
?
""
:
"/"
)
+
resource
.
getURL
().
toString
().
substring
(
baseUrlString
.
length
());
}
catch
(
IOException
e
)
{
throw
new
UncheckedIOException
(
e
);
}
}
}
\ No newline at end of file
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/DB2Dialect.java
浏览文件 @
2a46b084
...
...
@@ -21,7 +21,7 @@ public class DB2Dialect extends Dialect {
@Override
public
String
getLimitString
(
String
sql
,
JpaPagination
pagination
)
{
if
(
pagination
.
getPage
Results
()
==
0
)
{
if
(
pagination
.
getPage
Size
()
==
0
)
{
return
sql
+
" fetch first "
+
pagination
.
getStartRow
()
+
" rows only"
;
}
StringBuilder
pagingSelectSql
=
new
StringBuilder
(
sql
.
length
()
+
200
)
...
...
@@ -30,7 +30,7 @@ public class DB2Dialect extends Dialect {
)
.
append
(
sql
)
//nest the main query in an outer select
.
append
(
" fetch first "
)
.
append
(
pagination
.
getPage
Results
())
.
append
(
pagination
.
getPage
Size
())
.
append
(
" rows only ) as inner2_ ) as inner1_ where rownumber_ > "
)
.
append
(
pagination
.
getStartRow
())
.
append
(
" order by rownumber_"
);
...
...
@@ -40,9 +40,9 @@ public class DB2Dialect extends Dialect {
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -53,11 +53,11 @@ public class DB2Dialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/DerbyDialect.java
浏览文件 @
2a46b084
...
...
@@ -31,7 +31,7 @@ public class DerbyDialect extends Dialect {
pagingSelectSql
.
append
(
" offset "
).
append
(
pagination
.
getStartRow
()
).
append
(
" rows fetch next "
);
}
pagingSelectSql
.
append
(
pagination
.
getPage
Results
()
).
append
(
" rows only"
);
pagingSelectSql
.
append
(
pagination
.
getPage
Size
()
).
append
(
" rows only"
);
return
pagingSelectSql
.
toString
();
...
...
@@ -40,9 +40,9 @@ public class DerbyDialect extends Dialect {
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -53,11 +53,11 @@ public class DerbyDialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/MySQLDialect.java
浏览文件 @
2a46b084
...
...
@@ -28,21 +28,21 @@ public class MySQLDialect extends Dialect {
public
String
getLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
pagination
.
calculate
();
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getStartRow
()+
" , "
+
pagination
.
getPage
Results
();
}
else
if
(
pagination
.
getPage
Results
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Results
();
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getStartRow
()+
" , "
+
pagination
.
getPage
Size
();
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Size
();
}
else
{
return
sql
+
" LIMIT "
+
pagination
.
getPage
Results
();
return
sql
+
" LIMIT "
+
pagination
.
getPage
Size
();
}
}
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -53,11 +53,11 @@ public class MySQLDialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/OracleDialect.java
浏览文件 @
2a46b084
...
...
@@ -21,7 +21,7 @@ public class OracleDialect extends Dialect {
@Override
public
String
getLimitString
(
String
sql
,
JpaPagination
pagination
)
{
if
(
pagination
.
getPage
Results
()
==
0
)
{
if
(
pagination
.
getPage
Size
()
==
0
)
{
return
sql
+
" fetch first "
+
pagination
.
getStartRow
()
+
" rows only"
;
}
StringBuilder
pagingSelect
=
new
StringBuilder
(
sql
.
length
()
+
200
)
...
...
@@ -40,9 +40,9 @@ public class OracleDialect extends Dialect {
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -53,11 +53,11 @@ public class OracleDialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/PostgreSQLDialect.java
浏览文件 @
2a46b084
...
...
@@ -21,10 +21,10 @@ public class PostgreSQLDialect extends Dialect {
@Override
public
String
getLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Results
()+
" , "
+
pagination
.
getStartRow
()
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Results
();
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Size
()+
" , "
+
pagination
.
getStartRow
()
;
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT "
+
pagination
.
getPage
Size
();
}
else
{
return
sql
+
" LIMIT 1000"
;
}
...
...
@@ -33,9 +33,9 @@ public class PostgreSQLDialect extends Dialect {
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -46,11 +46,11 @@ public class PostgreSQLDialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/dialect/SQLServerDialect.java
浏览文件 @
2a46b084
...
...
@@ -23,9 +23,9 @@ public class SQLServerDialect extends Dialect {
@Override
public
String
getLimitString
(
String
sql
,
JpaPagination
pagination
)
{
StringBuilder
pagingSelectSql
=
new
StringBuilder
(
""
);
if
(
pagination
.
getPage
Results
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
){
pagingSelectSql
.
append
(
"SELECT TOP "
+
pagination
.
getPage
Results
()+
" * FROM ( "
);
pagingSelectSql
.
append
(
"SELECT TOP "
+
pagination
.
getPage
Size
()+
" * FROM ( "
);
pagingSelectSql
.
append
(
"SELECT ROW_NUMBER() OVER() AS ROWNUMBER,MYBATIS_QUERY_TEMP_TABLE.* FROM ( "
);
pagingSelectSql
.
append
(
"MYBATIS_QUERY_TEMP_TABLE ) MYBATIS_QUERY_TEMP_PAGE "
);
if
(
pagination
.
getStartRow
()>
0
){
...
...
@@ -40,9 +40,9 @@ public class SQLServerDialect extends Dialect {
@Override
public
String
getPreparedStatementLimitString
(
String
sql
,
JpaPagination
pagination
)
{
//LIMIT #{pageResults} OFFSET #{startRow}
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
return
sql
+
" LIMIT ? , ?"
;
}
else
if
(
pagination
.
getPage
Results
()>
0
){
}
else
if
(
pagination
.
getPage
Size
()>
0
){
return
sql
+
" LIMIT ? "
;
}
else
{
return
sql
+
" LIMIT ?"
;
...
...
@@ -53,11 +53,11 @@ public class SQLServerDialect extends Dialect {
public
void
setLimitParamters
(
PreparedStatement
preparedStatement
,
int
parameterSize
,
JpaPagination
pagination
)
{
try
{
if
(
pagination
.
getPage
Results
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
}
else
if
(
pagination
.
getPage
Results
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Results
());
if
(
pagination
.
getPage
Size
()>
0
&&
pagination
.
getStartRow
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
if
(
pagination
.
getPage
Size
()>
0
){
preparedStatement
.
setInt
(++
parameterSize
,
pagination
.
getPage
Size
());
}
else
{
preparedStatement
.
setInt
(++
parameterSize
,
1000
);
}
...
...
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaBaseService.java
浏览文件 @
2a46b084
...
...
@@ -110,7 +110,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
*/
public
JpaPageResults
<
T
>
queryPageResults
(
T
entity
)
{
entity
.
setPageResultSelectUUID
(
entity
.
generateId
());
entity
.
setStartRow
(
calculateStartRow
(
entity
.
getPage
()
,
entity
.
getPageResults
()));
entity
.
setStartRow
(
calculateStartRow
(
entity
.
getPage
Number
()
,
entity
.
getPageSize
()));
entity
.
setPageable
(
true
);
List
<
T
>
resultslist
=
getMapper
().
queryPageResults
(
entity
);
...
...
@@ -118,13 +118,13 @@ public class JpaBaseService <T extends JpaBaseDomain> {
Integer
totalPage
=
resultslist
.
size
();
Integer
totalCount
=
0
;
if
(
entity
.
getPage
()==
1
&&
totalPage
<
entity
.
getPageResults
())
{
if
(
entity
.
getPage
Number
()==
1
&&
totalPage
<
entity
.
getPageSize
())
{
totalCount
=
totalPage
;
}
else
{
totalCount
=
parseCount
(
getMapper
().
queryPageResultsCount
(
entity
));
}
return
new
JpaPageResults
<
T
>(
entity
.
getPage
(),
entity
.
getPageResults
(),
totalPage
,
totalCount
,
resultslist
);
return
new
JpaPageResults
<
T
>(
entity
.
getPage
Number
(),
entity
.
getPageSize
(),
totalPage
,
totalCount
,
resultslist
);
}
...
...
@@ -138,7 +138,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
@SuppressWarnings
(
"unchecked"
)
public
JpaPageResults
<
T
>
queryPageResults
(
String
mapperId
,
T
entity
)
{
entity
.
setPageResultSelectUUID
(
entity
.
generateId
());
entity
.
setStartRow
(
calculateStartRow
(
entity
.
getPage
()
,
entity
.
getPageResults
()));
entity
.
setStartRow
(
calculateStartRow
(
entity
.
getPage
Number
()
,
entity
.
getPageSize
()));
entity
.
setPageable
(
true
);
List
<
T
>
resultslist
=
null
;
...
...
@@ -152,13 +152,13 @@ public class JpaBaseService <T extends JpaBaseDomain> {
Integer
totalPage
=
resultslist
.
size
();
Integer
totalCount
=
0
;
if
(
entity
.
getPage
()==
1
&&
totalPage
<
entity
.
getPageResults
())
{
if
(
entity
.
getPage
Number
()==
1
&&
totalPage
<
entity
.
getPageSize
())
{
totalCount
=
totalPage
;
}
else
{
totalCount
=
parseCount
(
getMapper
().
queryPageResultsCount
(
entity
));
}
return
new
JpaPageResults
<
T
>(
entity
.
getPage
(),
entity
.
getPageResults
(),
totalPage
,
totalCount
,
resultslist
);
return
new
JpaPageResults
<
T
>(
entity
.
getPage
Number
(),
entity
.
getPageSize
(),
totalPage
,
totalCount
,
resultslist
);
}
/**
...
...
@@ -373,7 +373,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
* @return
*/
public
Integer
calculateTotalPage
(
JpaBaseDomain
entity
,
Integer
totalCount
){
return
(
totalCount
+
entity
.
getPage
Results
()
-
1
)
/
entity
.
getPageResults
();
return
(
totalCount
+
entity
.
getPage
Size
()
-
1
)
/
entity
.
getPageSize
();
}
/**
...
...
@@ -382,7 +382,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
* @param pageResults
* @return
*/
public
Integer
calculateStartRow
(
Integer
page
,
Integer
page
Results
){
return
(
page
-
1
)
*
page
Results
;
public
Integer
calculateStartRow
(
Integer
page
,
Integer
page
Size
){
return
(
page
-
1
)
*
page
Size
;
}
}
mybatis-jpa-extra-core/src/main/java/org/apache/mybatis/jpa/persistence/JpaPagination.java
浏览文件 @
2a46b084
...
...
@@ -18,12 +18,12 @@ public class JpaPagination {
*
*/
@JsonIgnore
protected
int
page
Results
=
20
;
protected
int
page
Size
=
20
;
/**
*
*/
@JsonIgnore
protected
int
page
=
1
;
protected
int
page
Number
=
1
;
/**
*
*/
...
...
@@ -41,7 +41,7 @@ public class JpaPagination {
*
*/
@JsonIgnore
protected
String
sor
d
;
protected
String
sor
tOrder
;
/**
*
*/
...
...
@@ -67,16 +67,16 @@ public class JpaPagination {
public
void
setRows
(
int
rows
)
{
this
.
rows
=
rows
;
this
.
page
Results
=
rows
;
this
.
page
Size
=
rows
;
calculate
();
}
@JsonIgnore
public
int
getPage
()
{
return
page
;
public
int
getPage
Number
()
{
return
page
Number
;
}
public
void
setPage
(
int
page
)
{
this
.
page
=
page
;
public
void
setPage
Number
(
int
pageNumber
)
{
this
.
page
Number
=
pageNumber
;
calculate
();
}
@JsonIgnore
...
...
@@ -89,12 +89,12 @@ public class JpaPagination {
setSortKey
();
}
@JsonIgnore
public
String
getSor
d
()
{
return
sor
d
;
public
String
getSor
tOrder
()
{
return
sor
tOrder
;
}
public
void
setSor
d
(
String
sord
)
{
this
.
sor
d
=
sord
;
public
void
setSor
tOrder
(
String
sortOrder
)
{
this
.
sor
tOrder
=
sortOrder
;
setSortKey
();
}
...
...
@@ -116,18 +116,18 @@ public class JpaPagination {
}
public
void
calculate
()
{
if
(
this
.
page
>=
1
&&
this
.
pageResults
>
0
){
startRow
=
(
this
.
page
-
1
)
*
this
.
pageResults
;
endRow
=
startRow
+
this
.
page
Results
;
if
(
this
.
page
Number
>=
1
&&
this
.
pageSize
>
0
){
startRow
=
(
this
.
page
Number
-
1
)
*
this
.
pageSize
;
endRow
=
startRow
+
this
.
page
Size
;
}
}
@JsonIgnore
public
int
getPage
Results
()
{
return
page
Results
;
public
int
getPage
Size
()
{
return
page
Size
;
}
public
void
setPage
Results
(
int
pageResults
)
{
this
.
page
Results
=
pageResults
;
public
void
setPage
Size
(
int
pageSize
)
{
this
.
page
Size
=
pageSize
;
}
@JsonIgnore
public
String
getSortKey
()
{
...
...
@@ -138,8 +138,8 @@ public class JpaPagination {
* create sortKey from sidx & sord,eg order by name asc
*/
public
void
setSortKey
()
{
if
(
sidx
!=
null
&&
sor
d
!=
null
&&
!
sidx
.
equals
(
""
)
&&
!
sord
.
equals
(
""
)){
sortKey
=
" "
+
sidx
+
" "
+
sor
d
+
" "
;
if
(
sidx
!=
null
&&
sor
tOrder
!=
null
&&
!
sidx
.
equals
(
""
)
&&
!
sortOrder
.
equals
(
""
)){
sortKey
=
" "
+
sidx
+
" "
+
sor
tOrder
+
" "
;
setOrderBy
();
}
...
...
@@ -158,7 +158,7 @@ public class JpaPagination {
*/
public
void
setOrderBy
()
{
if
(
sortKey
!=
null
&&
!
sortKey
.
equals
(
""
)){
orderBy
=
" ORDER BY "
+
sidx
+
" "
+
sor
d
+
" "
;
orderBy
=
" ORDER BY "
+
sidx
+
" "
+
sor
tOrder
+
" "
;
}
}
...
...
@@ -192,9 +192,9 @@ public class JpaPagination {
*/
@Override
public
String
toString
()
{
return
"Pagination [rows="
+
rows
+
", pageResults="
+
page
Results
+
", page="
+
page
+
", startRow="
+
startRow
+
", endRow="
+
endRow
+
", sidx="
+
sidx
+
", sord="
+
sor
d
+
", sortKey="
return
"Pagination [rows="
+
rows
+
", pageResults="
+
page
Size
+
", page="
+
page
Number
+
", startRow="
+
startRow
+
", endRow="
+
endRow
+
", sidx="
+
sidx
+
", sord="
+
sor
tOrder
+
", sortKey="
+
sortKey
+
", orderBy="
+
orderBy
+
", pageable="
+
pageable
+
"]"
;
}
...
...
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/MyBatisTestRunner.java
浏览文件 @
2a46b084
...
...
@@ -80,8 +80,8 @@ public class MyBatisTestRunner {
//student.setId("af04d610-6092-481e-9558-30bd63ef783c");
student
.
setStdGender
(
"M"
);
//student.setStdMajor(政治");
student
.
setPage
Results
(
10
);
student
.
setPage
(
2
);
student
.
setPage
Size
(
10
);
student
.
setPage
Number
(
2
);
_logger
.
info
(
"queryPageResults "
+
service
.
queryPageResults
(
student
));
}
...
...
@@ -92,8 +92,8 @@ public class MyBatisTestRunner {
Students
student
=
new
Students
();
student
.
setStdGender
(
"M"
);
//student.setStdMajor(政治");
student
.
setPage
Results
(
10
);
student
.
setPage
(
2
);
student
.
setPage
Size
(
10
);
student
.
setPage
Number
(
2
);
_logger
.
info
(
"queryPageResults by mapperId "
+
service
.
queryPageResults
(
"queryPageResults1"
,
student
));
...
...
mybatis-jpa-extra-core/src/test/java/org/apache/mybatis/jpa/test/domain/DemoDomain.java
浏览文件 @
2a46b084
...
...
@@ -39,8 +39,6 @@ public class DemoDomain extends JpaBaseDomain{
protected
int
status
;
protected
int
sortOrder
;
protected
String
createdBy
;
@JsonSerialize
(
using
=
JsonDateTimeSerializer
.
class
)
...
...
@@ -101,23 +99,6 @@ public class DemoDomain extends JpaBaseDomain{
/**
* @return the sortOrder
*/
public
int
getSortOrder
()
{
return
sortOrder
;
}
/**
* @param sortOrder the sortOrder to set
*/
public
void
setSortOrder
(
int
sortOrder
)
{
this
.
sortOrder
=
sortOrder
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录