From 2b7d13e45f1ce3a97f3d4d5a2a58d4286adaa85c Mon Sep 17 00:00:00 2001 From: dbetterton Date: Thu, 2 Jun 2016 07:18:05 -0500 Subject: [PATCH 1/4] Use the min/max dates from Oracle directly, not theoretical maximums --- .../github/tennaito/rsql/jpa/PredicateBuilder.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java index 8bbf0de..15d2262 100755 --- a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java +++ b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -68,8 +69,17 @@ public final class PredicateBuilder { public static final Character LIKE_WILDCARD = '*'; - private static final Date START_DATE = new Date(0L) ; - private static final Date END_DATE = new Date(99999999999999999L) ; + private static final Date START_DATE; + private static final Date END_DATE; + + static { + Calendar cal = Calendar.getInstance(); + cal.set( 9999, Calendar.DECEMBER, 31); + END_DATE = cal.getTime(); + cal.set( 4712, Calendar.JANUARY, 1); + cal.set(Calendar.ERA, GregorianCalendar.BC); + START_DATE = cal.getTime(); + } /** * Private constructor. From 371164fb8cc8f233b1dff61d714e3c13bd5a5480 Mon Sep 17 00:00:00 2001 From: dbetterton Date: Thu, 2 Jun 2016 10:00:40 -0500 Subject: [PATCH 2/4] Make the start of the range AD as well --- .../java/com/github/tennaito/rsql/jpa/PredicateBuilder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java index 15d2262..77bb25d 100755 --- a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java +++ b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java @@ -73,11 +73,13 @@ public final class PredicateBuilder { private static final Date END_DATE; static { + // + // Use a date range that Oracle can cope with + // Calendar cal = Calendar.getInstance(); cal.set( 9999, Calendar.DECEMBER, 31); END_DATE = cal.getTime(); - cal.set( 4712, Calendar.JANUARY, 1); - cal.set(Calendar.ERA, GregorianCalendar.BC); + cal.set( 5, Calendar.JANUARY, 1); // Use Jan 1, 5 AD, since that's where the Roman's sort of got it together with leap years. START_DATE = cal.getTime(); } From 6d63e2cb77c453bb90a38fd3b60e67a95238003d Mon Sep 17 00:00:00 2001 From: dbetterton Date: Thu, 2 Jun 2016 10:04:57 -0500 Subject: [PATCH 3/4] Added more on reason for date range and removed un-needed import --- .../java/com/github/tennaito/rsql/jpa/PredicateBuilder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java index 77bb25d..468e724 100755 --- a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java +++ b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java @@ -46,7 +46,6 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -74,7 +73,7 @@ public final class PredicateBuilder { static { // - // Use a date range that Oracle can cope with + // Use a date range that Oracle can cope with - apparently the years around 1 BC and 1 AD are messed up in Oracle - known bug // Calendar cal = Calendar.getInstance(); cal.set( 9999, Calendar.DECEMBER, 31); From b732f0153141b9f9755c5099a6b70f9da60fd3d3 Mon Sep 17 00:00:00 2001 From: dbetterton Date: Thu, 2 Jun 2016 10:07:37 -0500 Subject: [PATCH 4/4] Update version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1a5e3b4..1e59fd6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.tennaito rsql-jpa - 2.0.6-SNAPSHOT + 2.0.7-SNAPSHOT jar @@ -52,7 +52,7 @@ 2.0.0 - + org.eclipse.persistence javax.persistence