java.lang.IllegalArgumentException: Parameter value did not match expected type Specification

谁说我不能喝 提交于 2019-12-11 15:36:44

问题


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()+"%");
    };
}

来源:https://stackoverflow.com/questions/54077381/java-lang-illegalargumentexception-parameter-value-did-not-match-expected-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!