I'm pretty new in JPA/Hibernate and spring boot, and I'd like to do dynamic querys depeding on the received params. I was following this approach https://www.baeldung.com/spring-data-jpa-query , but I'm getting an error:
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 Reglas2doNivelRepositoryCustomImpl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.