栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

~~在Spring 5 JPA findOne()中~~ 获取`Long无法转换为 ~~Example`~~

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

~~在Spring 5 JPA findOne()中~~ 获取`Long无法转换为 ~~Example`~~

~~~~

由于Spring 5和Spring数据JPA 2.0.0.M3的一部分,我可以看到

findOne
法中删除 CrudRepository 到一个在
QueryByExampleExecutor 所以最好是变化
Optional<T> findById(IDarg0);
的,而不是
findOne
方法,请在下面找到:

@NoRepositoryBeanpublic interface CrudRepository<T, ID> extends Repository<T, ID> {    <S extends T> S save(S arg0);    <S extends T> Iterable<S> saveAll(Iterable<S> arg0);    Optional<T> findById(ID arg0);    boolean existsById(ID arg0);    Iterable<T> findAll();    Iterable<T> findAllById(Iterable<ID> arg0);    long count();    void deleteById(ID arg0);    void delete(T arg0);    void deleteAll(Iterable<? extends T> arg0);    void deleteAll();}

QueryByExampleExecutor

public abstract interface QueryByExampleExecutor<T> {    public abstract <S extends T> S findOne(Example<S> paramExample);    public abstract <S extends T> Iterable<S> findAll(Example<S> paramExample);    public abstract <S extends T> Iterable<S> findAll(Example<S> paramExample, Sort paramSort);    public abstract <S extends T> Page<S> findAll(Example<S> paramExample, Pageable paramPageable);    public abstract <S extends T> long count(Example<S> paramExample);    public abstract <S extends T> boolean exists(Example<S> paramExample);}

检查QueryForExampleExecutor上的文档:

https://docs.spring.io/spring-
data/jpa/docs/2.0.0.RC2/reference/html/



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/417127.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号