java.lang.IllegalArgumentException: Parameter valu

2019-08-30 02:01发布

问题:

I try to implement a search in Spring Boot with Specifications. Finally it searches something, but i get this error:

java.lang.IllegalArgumentException: Parameter value [com.auth0.samples.bootfaces.TelefonbuchSpecifications$$Lambda$11/1542138726@62f6f6fb] did not match expected type [java.lang.String (n/a)]

I have no idea. I think I implemented it right, but yes whatever. I'll show you the necessary code: Call in the searchController: if (!vorname.isEmpty()) { eintraege = telefonbuchRepository.findByVorname(TelefonbuchSpecifications.hasVorname(vorname));

TelefonbuchRepository:

public interface TelefonbuchRepository extends JpaRepository, JpaSpecificationExecutor {

public List<Telefonbuch> findByVorname(Specification<Telefonbuch> spec);

Specification:

public interface Specification { Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb);

TelefonbuchSpecification:

public static Specification<Telefonbuch> hasVorname(String vorname) {
    return (root, query, cb) -> {
        return cb.equal(root.get(Telefonbuch_.vorname), "%"+vorname.toLowerCase()+"%");
    };
}