Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract
Ok, I got the solution for this. I should not be using Table name, it should be always Model/Entity name. This (@Query("SELECT v FROM Visit v WHERE v.visitType='NEW'")) resolves problem.
@Repository
public interface VisitRepository extends JpaRepository<Visit, Integer>,
QueryDslPredicateExecutor<Visit>{
List<Visit> findByVisitType(String visitType);
@Query("SELECT v FROM Visit v WHERE v.visitType='NEW'")
List<Visit> findByVisitType();
}
People who are still getting error even after trying above methods can try this (this solved my problem)
@Query(value = "normal Sql query", nativeQuery=true).
specify value and nativeQuery