简体   繁体   English

动态 JPA 查询:“找不到属性”

[英]Dynamic JPA Querys : “property not found”

I'm pretty new in JPA/Hibernate and spring boot, and I'd like to do dynamic querys depeding on the received params.我在 JPA/Hibernate 和 spring 引导中相当新,我想根据收到的参数进行动态查询。 I was following this approach https://www.baeldung.com/spring-data-jpa-query , but I'm getting an error:我正在遵循这种方法https://www.baeldung.com/spring-data-jpa-query ,但出现错误:

Error starting ApplicationContext. ERROR --- [  restartedMain] o.s.b.SpringApplication                  : Application startup failedCaused by: org.springframework.data.mapping.PropertyReferenceException: No property getReglas2doNivelFiltradas found for type Reglas2doNivel!

This how I implemented:这就是我实现的方式:

Repository:存储库:

@Repository
public interface Reglas2doNivelRepository extends JpaRepository<Reglas2doNivel, Long>, Reglas2doNivelRepositoryCustom {

    @Modifying
    @Query("Update Reglas1erNivel r set r.activo='N' where r.id_regla = ?1")
    void desactivarRegla2doNivel(Long iRegla);

    @Query("Select r from Reglas2doNivel r where r.sociedad.id_sociedad = ?1")
    List<Reglas2doNivel> getReglas2doNivelBySociedad(int companyID);

}

Custom repository interface:自定义仓库界面:

public interface Reglas2doNivelRepositoryCustom {

    List<Reglas2doNivel> getReglas2doNivelFiltradas(int company, List<Integer> areasId,  int ordenDesde, int ordenHasta, String nemoTecnico);
}

Custom Repository implemetation:自定义存储库实现:

public class Reglas2doNivelRepositoryCustomImpl implements Reglas2doNivelRepositoryCustom {

    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public List<Reglas2doNivel> getReglas2doNivelFiltradas(int company, List<Integer> areasId, int ordenDesde,
            int ordenHasta, String nemoTecnico) {
        return null;
    }

}

Service:服务:

@Override
public List<Reglas2doNivel> getReglas2doNivelBySociedad(int companyID) {
            
    return reglas2doNivelRepository.getReglas2doNivelBySociedad(companyID);
}

What's wrong?怎么了?

Thanks谢谢

Add @NoRepositoryBean annotation to the Reglas2doNivelRepositoryCustom interface and @Repository to the Reglas2doNivelRepositoryCustomImplReglas2doNivelRepositoryCustom接口中添加@NoRepositoryBean注解,在@Repository中添加Reglas2doNivelRepositoryCustomImpl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM