Hi I have extended a JpaRepository interface in following way.
public interface StudentRepository extends JpaRepository<Student,Integer>
{
@Query(value= "SELECT s.id FROM student as s where s.createdat > ADDDATE(CURRENT_DATE, :maxage ", nativeQuery = true )
public List<Integer> findWaitingStudentIds(@Param("maxage")int maxAge);
}
Here is the Entity
class.
@Entity(name="student ")
public class Student implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(unique=true, nullable=false)
private Integer id;
@Temporal(TemporalType.TIMESTAMP)
@Column(updatable = false,insertable = false)
private Date createdat;
}
I want to add cache for "List findWaitingStudentIds" method. How can I achieve this?