I am creating a Specification that can do partial searches on numbers. My overridden toPredicate method:
/** The not. */
@Builder.Default
boolean not = false;
/** The property. */
@Builder.Default
String property = "";
/** The value. */
@Builder.Default
String value = "";
.......
@Override
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
if (!this.value.contains("%"))
this.value = "%" + this.value + "%";
if (this.not)
return builder.notLike(root.get(this.property).as(String.class), this.value, ''');
else
return builder.like(root.get(this.property).as(String.class), this.value, ''');
}
which results in this where clause:
select * from customer where cast(cust_number as varchar2(4000 char)) .....
I am concerned casting the number to a 4000 char varchar2 on the database side will become a performance issue on bigger data sets.
Is there a way to limit the number of characters the system sets or use a different datatype on the Java side?