package com.example.demo.Repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.example.demo.entity.WomenCareEntity;
@Repository
public interface WomenCareRepository extends JpaRepository<WomenCareEntity, Integer> {
@Query(value="select lakh_5 from women_1A_premium where :age >=min_age and :age <=max_age and year=1",nativeQuery=true)
int findPremium(int age);
"message": "JDBC exception executing SQL [select lakh_5 from women_1A_premium where ? >=min_age and ? <=max_age and year=1]; SQL [n/a]".
This is the error message. What do I need to do?
It need an extra annotation in function parameter.
Correct one is as below:
@Repository
public interface WomenCareRepository extends JpaRepository<WomenCareEntity, Integer> {
@Query(value="select lakh_5 from women_1A_premium where :age >=min_age and :age <=max_age and year=1",nativeQuery=true)
int findPremium(@Param("age") int age);