Repository: olingo-odata2
Updated Branches:
  refs/heads/master 1f9dbe462 -> e2b2b191f


[OLINGO-1298] Hibernate latest version compliance


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/e2b2b191
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/e2b2b191
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/e2b2b191

Branch: refs/heads/master
Commit: e2b2b191f86fa5ee93a8f452c4392dc14a6648cc
Parents: 1f9dbe4
Author: Archana Rai <archana....@sap.com>
Authored: Wed Sep 26 16:23:08 2018 +0530
Committer: Archana Rai <archana....@sap.com>
Committed: Wed Sep 26 16:23:08 2018 +0530

----------------------------------------------------------------------
 .../jpa/processor/core/access/data/JPAPage.java | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/e2b2b191/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
----------------------------------------------------------------------
diff --git 
a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
 
b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
index d3dc88b..4effd5b 100644
--- 
a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
+++ 
b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAPage.java
@@ -72,8 +72,8 @@ public class JPAPage implements JPAPaging {
     private List<Object> pagedEntities;
 
     private static class TopSkip {
-      public int top;
-      public int skip;
+      public Integer top;
+      public Integer skip;
     }
 
     public JPAPageBuilder() {}
@@ -99,10 +99,15 @@ public class JPAPage implements JPAPaging {
     private JPAPage buildFromEntities() {
       TopSkip topSkip = formulateTopSkip();
       pagedEntities = new ArrayList<Object>();
-      if (topSkip.skip <= 0) {
-        topSkip.skip = 1;
+      Integer top = topSkip.top;
+      Integer skip = topSkip.skip;
+      if (skip == null || topSkip.skip <= 0) {
+        skip = 1;
       }
-      for (int i = topSkip.skip - 1, j = 0; (j < topSkip.top && i < 
entities.size()); j++) {
+      if(top == null || topSkip.top <= 0){
+        top = 0;
+      }
+      for (int i = skip - 1, j = 0; (j < top && i < entities.size()); j++) {
         pagedEntities.add(entities.get(i++));
       }
       formulateNextPage();
@@ -112,8 +117,12 @@ public class JPAPage implements JPAPaging {
     @SuppressWarnings("unchecked")
     private JPAPage buildFromQuery() {
       TopSkip topSkip = formulateTopSkip();
-      query.setFirstResult(topSkip.skip);
-      query.setMaxResults(topSkip.top);
+      if(topSkip.skip != null){
+        query.setFirstResult(topSkip.skip);
+      }
+      if(topSkip.top != null){
+        query.setMaxResults(topSkip.top);
+      }
       pagedEntities = query.getResultList();
       formulateNextPage();
       return new JPAPage(startPage, nextPage, pagedEntities, pageSize);

Reply via email to