Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 动态JPA查询:";“未找到财产”;_Java_Spring_Spring Boot_Hibernate_Jpa - Fatal编程技术网

Java 动态JPA查询:";“未找到财产”;

Java 动态JPA查询:";“未找到财产”;,java,spring,spring-boot,hibernate,jpa,Java,Spring,Spring Boot,Hibernate,Jpa,我对JPA/Hibernate和spring boot非常陌生,我想根据收到的参数进行动态查询。我采用了这种方法,但我得到了一个错误: Error starting ApplicationContext. ERROR --- [ restartedMain] o.s.b.SpringApplication : Application startup failedCaused by: org.springframework.data.mapping.Proper

我对JPA/Hibernate和spring boot非常陌生,我想根据收到的参数进行动态查询。我采用了这种方法,但我得到了一个错误:

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!
这是我如何实施的:

存储库:

@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);

}
@存储库
公共接口Reglas2doNivelRepository扩展了JpaRepository、Reglas2doNivelRepositoryCustom{
@修改
@查询(“更新Reglas1erNivel r set r.activo='N'其中r.id\u regla=?1”)
void desactivatarregla2donivel(长iRegla);
@查询(“从Reglas2doNivel r中选择r,其中r.sociedad.id_sociedad=?1”)
列出getReglas2doNivelBySociedad(int companyID);
}
自定义存储库界面:

public interface Reglas2doNivelRepositoryCustom {

    List<Reglas2doNivel> getReglas2doNivelFiltradas(int company, List<Integer> areasId,  int ordenDesde, int ordenHasta, String nemoTecnico);
}
公共接口Reglas2doNivelRepositoryCustom{
列出getReglas2doNivelFiltradas(公司内部、区域SID列表、内部ordenDesde、内部ordenHasta、字符串nemoTecnico);
}
自定义存储库实施:

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;
    }

}
公共类Reglas2doNivelRepositoryCustomImpl实现Reglas2doNivelRepositoryCustom{
@持久上下文
私人实体管理者实体管理者;
@凌驾
公共列表getReglas2doNivelFiltradas,
内特奥登哈斯塔,字符串nemoTecnico){
返回null;
}
}
服务:

@Override
public List<Reglas2doNivel> getReglas2doNivelBySociedad(int companyID) {
            
    return reglas2doNivelRepository.getReglas2doNivelBySociedad(companyID);
}
@覆盖
公共列表getReglas2doNivelBySociedad(int companyID){
返回reglas2doNivelRepository.getReglas2doNivelBySociedad(companyID);
}
怎么了


感谢将
@NoRepositoryBean
注释添加到
Reglas2doNivelRepositoryCustom
界面,并将
@repositorycustomimpl
@NoRepositoryBean
注释添加到
Reglas2doNivelRepositoryCustom
界面和
@repositorycustom
reglas2doniverepositorycustomimpl

发送通知,说明您没有遵循正确的约定。未检测到自定义实现,因此它将尝试从该方法进行查询(失败)。确保名称与interface+
Impl
的名称完全相同,并且两个文件位于同一个包中,而不是不同的包中!。嗨,谢谢你的回答,我不明白你的意思。名称是:Reglas2doNivelRepositoryCustomImpl和Reglas2doNivelRepositoryCustom,同样是+Impl。什么是错误的名称?而且它们也必须在同一个包中。是的,它们在同一个包中,这三个位置是您没有遵循正确的约定的。未检测到自定义实现,因此它将尝试从该方法进行查询(失败)。确保名称与interface+
Impl
的名称完全相同,并且两个文件位于同一个包中,而不是不同的包中!。嗨,谢谢你的回答,我不明白你的意思。名称是:Reglas2doNivelRepositoryCustomImpl和Reglas2doNivelRepositoryCustom,同样是+Impl。什么是错误的名称?它们也必须在同一个包中。是的,它们在同一个包中,即三个存储库中