i have BLOB column in Mysql database.
In java this column parsed as string array:
@Column(
name = "categories",
nullable = false,
length = 2048
)
private String[] categories;
This class have spring repository method findAll which uses predicates from Specification for filtering:
Page<Campaign> findAll(Specification<Campaign> spec, Pageable pageable);
For colum with type String we create predicate with next code example:
public static <T extends AbstractPersistable> Predicate likeLower(Root<T> root, CriteriaBuilder cb, String name, String value) {
if (isBlank(value)) {
return null;
}
return cb.like(cb.lower(root.get(name)), '%' + value + '%');
}
im create predicate with code below :
predicates.add(likeLower(root, cb, "categories", filterCategories));
When i run query SELECT * FROM persona_adserver.campaign where categories like '%asino%';
in mysql directly i receive 209 rows as result.
But when i pass predicate to repositoy i have exception:
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [%asino%] did not match expected type [[Ljava.lang.String; (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [%asino%] did not match expected type [[Ljava.lang.String; (n/a)]
Update 1
filterCategories comes from api request as String param