Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jh-boot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Hrabal
jh-boot
Commits
d49799fa
Commit
d49799fa
authored
Apr 05, 2020
by
Jan Hrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
c4a30006
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
AbstractHibernateRepository.java
...ain/java/com/jh/boot/jpa/AbstractHibernateRepository.java
+8
-0
No files found.
src/main/java/com/jh/boot/jpa/AbstractHibernateRepository.java
View file @
d49799fa
...
@@ -16,12 +16,16 @@ import javax.persistence.PersistenceContext;
...
@@ -16,12 +16,16 @@ import javax.persistence.PersistenceContext;
import
javax.persistence.Query
;
import
javax.persistence.Query
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Order
;
import
javax.persistence.criteria.Root
;
import
javax.persistence.criteria.Root
;
import
org.hibernate.query.NativeQuery
;
import
org.hibernate.query.NativeQuery
;
import
org.hibernate.query.criteria.internal.OrderImpl
;
import
org.springframework.util.StringUtils
;
import
com.jh.boot.web.list.Page
;
import
com.jh.boot.web.list.Page
;
import
com.jh.boot.web.list.PagingInfo
;
import
com.jh.boot.web.list.PagingInfo
;
import
com.jh.boot.web.list.SortTrend
;
/**
/**
...
@@ -138,6 +142,10 @@ public abstract class AbstractHibernateRepository {
...
@@ -138,6 +142,10 @@ public abstract class AbstractHibernateRepository {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
protected
<
T
>
Page
<
T
>
pagedCriteria
(
CriteriaBuilder
cb
,
CriteriaQuery
<
T
>
cq
,
Root
<
T
>
root
,
PagingInfo
pagingInfo
)
{
protected
<
T
>
Page
<
T
>
pagedCriteria
(
CriteriaBuilder
cb
,
CriteriaQuery
<
T
>
cq
,
Root
<
T
>
root
,
PagingInfo
pagingInfo
)
{
if
(
StringUtils
.
hasText
(
pagingInfo
.
getField
()))
{
cq
.
orderBy
(
new
OrderImpl
(
root
.
get
(
pagingInfo
.
getField
()),
pagingInfo
.
getTrend
()
==
SortTrend
.
ASCENDING
));
}
Query
query
=
entityManager
.
createQuery
(
cq
);
Query
query
=
entityManager
.
createQuery
(
cq
);
query
.
setFirstResult
(
pagingInfo
.
getPage
()
*
pagingInfo
.
getPageSize
());
query
.
setFirstResult
(
pagingInfo
.
getPage
()
*
pagingInfo
.
getPageSize
());
query
.
setMaxResults
(
pagingInfo
.
getPageSize
());
query
.
setMaxResults
(
pagingInfo
.
getPageSize
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment