大佬教程收集整理的这篇文章主要介绍了~~在Spring 5 JPA findOne()中~~ 获取`Long无法转换为 ~~Example`~~,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
~~~~
由于Spring 5和Spring数据JPA 2.0.0.M3的一部分,我可以看到findOne
法中删除 到一个在 所以最好是变化Optional<T> findByID(ID
arg0);
的,而不是findOne
方法,请在下面找到:
@norepositoryBean
public 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();
}
:
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/
~~~~
我在argument mismatch; Long cAnnot be converted to
Example<S>
下面的代码中找到了findOne调用:
public Optional<AuditEvent> find(Long id) {
return Optional.ofNullable(persistenceAuditEventRepository.findOne(id))
.map(auditEventConverter::convertToAuditEvent);
}
上面的代码将转换为Spring 5和Spring Boot2。在原始的Spring 4和Spring Boot 1应用程序中,它可以正常工作。
任何想法我需要将上面的代码转换为?
以上是大佬教程为你收集整理的~~在Spring 5 JPA findOne()中~~ 获取`Long无法转换为 ~~Example`~~全部内容,希望文章能够帮你解决~~在Spring 5 JPA findOne()中~~ 获取`Long无法转换为 ~~Example`~~所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。