mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
Better error handling of null values in faceted search
This commit is contained in:
parent
bb3f9e7bcb
commit
83e9766eb0
@ -153,12 +153,15 @@ public class CustomJpaRepository extends SimpleJpaRepository {
|
||||
String fieldName = dbField.getJavaName();
|
||||
String v = filter.getValue();
|
||||
|
||||
Object value;
|
||||
Object value = null;
|
||||
|
||||
if (!v.isBlank()) {
|
||||
try {
|
||||
value = dbField.getType().parseValue(v);
|
||||
} catch (Exception e) {
|
||||
throw new DbAdminException("Invalid value `" + v + "` specified for field `" + dbField.getName() + "`");
|
||||
}
|
||||
}
|
||||
|
||||
if (op == CompareOperator.STRING_EQ) {
|
||||
if (value == null)
|
||||
@ -166,6 +169,7 @@ public class CustomJpaRepository extends SimpleJpaRepository {
|
||||
else
|
||||
finalPredicates.add(cb.equal(cb.lower(cb.toString(root.get(fieldName))), value.toString().toLowerCase()));
|
||||
} else if (op == CompareOperator.CONTAINS) {
|
||||
if (value != null)
|
||||
finalPredicates.add(
|
||||
cb.like(cb.lower(cb.toString(root.get(fieldName))), "%" + value.toString().toLowerCase() + "%")
|
||||
);
|
||||
@ -174,10 +178,12 @@ public class CustomJpaRepository extends SimpleJpaRepository {
|
||||
cb.equal(root.get(fieldName), value)
|
||||
);
|
||||
} else if (op == CompareOperator.GT) {
|
||||
if (value != null)
|
||||
finalPredicates.add(
|
||||
cb.greaterThan(root.get(fieldName), value.toString())
|
||||
);
|
||||
} else if (op == CompareOperator.LT) {
|
||||
if (value != null)
|
||||
finalPredicates.add(
|
||||
cb.lessThan(root.get(fieldName), value.toString())
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user