I am getting the below error when trying to bring the application up. I tried mltiple solution but none seems to be working.
*Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.test.base.repository.TestRespositoryCustom.findResultByCodeAndProfile(java.lang.String,java.lang.String)! No property findResultByCodeAndProfile found for type Test!
................ ................
............ 47 common frames omitted Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findResultByCodeAndProfile found for type Test! at org.springframework.data.mapping.PropertyPath.(PropertyPath.java:94) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.1.5.RELEASE.jar:2.1.5.RELEASE]*
My service class is calling findResultByCodeAndProfile method which call interface TestRespositoryCustom and the implementation of which is there below in TestRespositoryImpl class.
"Test.java is the entity class"
-- Service class.
@Autowired
TestRepository testRepository;
public void getHotelProfileLatestTest(String hotelCode)
{
List<TestDto> testList = testRepository.findResultByCodeAndProfile(secondaryCode, "profile");
//
//
}
-- TestRepository interface
public interface TestRepository extends BaseRepository<Test, Long>, TestRepositoryCustom {
{
@Query(TestQueries.NOTE_QRY)
Page<TestDto> getHistory(@Param("Key") String Key,
@Param("Value") String Value);
}
-- BaseRepository interface.
@NoRepositoryBean
public interface BaseRepository <T, ID extends Serializable> extends JpaRepository<T, ID>, QueryByExampleExecutor<T>{
}
-- TestRespositoryCustom
public interface TestRespositoryCustom
{
public List<TestDto> findResultByCodeAndProfile(String testObjKey, String testObjValue);
}
-- TestRespositoryImpl
public class TestRespositoryImpl extends BaseRepositoryCustom implements TestRespositoryCustom
{
@Override
public List<TestDto> findResultByCodeAndProfile(String testObjKey, String testObjValue)
{
String sql = TC_NOTE_QRY;
Query query = entityManager.createQuery(sql);
query.setMaxResults(3);
query.setParameter("testObjKey", testObjKey);
query.setParameter("testObjValue", testObjValue);
return (List) query.getResultList();
}
-- BaseRepositoryCustom
public class BaseRepositoryCustom {
@Value("${spring.jpa.properties.hibernate.default_schema}")
public String defaultSchema;
@PersistenceContext
protected EntityManager entityManager;
}