@@ -57,7 +57,7 @@ public static <X> Specification<X> notEqual(String field, Double value, Double t
5757 Expression <Double > doubleExpression = getColumnPath (root , field ).as (Double .class );
5858 return cb .or (
5959 cb .greaterThan (doubleExpression , value + tolerance ),
60- cb .lessThan (doubleExpression , value - tolerance )
60+ cb .lessThanOrEqualTo (doubleExpression , value )
6161 );
6262 };
6363 }
@@ -137,12 +137,17 @@ private static <X> Specification<X> appendTextFilterToSpecification(Specificatio
137137
138138 @ NotNull
139139 private static <X > Specification <X > appendNumberFilterToSpecification (Specification <X > specification , ResourceFilterDTO resourceFilter ) {
140- final double tolerance = 0.00001 ; // tolerance for comparison
141140 String value = resourceFilter .value ().toString ();
142- return createNumberPredicate (specification , resourceFilter , value , tolerance );
141+ return createNumberPredicate (specification , resourceFilter , value );
143142 }
144143
145- private static <X > Specification <X > createNumberPredicate (Specification <X > specification , ResourceFilterDTO resourceFilter , String value , double tolerance ) {
144+ private static <X > Specification <X > createNumberPredicate (Specification <X > specification , ResourceFilterDTO resourceFilter , String value ) {
145+ String [] splitValue = value .split ("\\ ." );
146+ int numberOfDecimalAfterDot = 0 ;
147+ if (splitValue .length > 1 ) {
148+ numberOfDecimalAfterDot = splitValue [1 ].length ();
149+ }
150+ final double tolerance = Math .pow (10 , -numberOfDecimalAfterDot ); // tolerance for comparison
146151 Double valueDouble = Double .valueOf (value );
147152 return switch (resourceFilter .type ()) {
148153 case NOT_EQUAL -> specification .and (notEqual (resourceFilter .column (), valueDouble , tolerance ));
0 commit comments