【发布时间】:2015-01-06 09:38:52
【问题描述】:
您好,我已经通过以下方式扩展了 JpaRepository 接口。
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);
}
这是Entity 类。
@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;
}
我想为“List findWaitingStudentIds”方法添加缓存。我怎样才能做到这一点?
【问题讨论】:
-
看here也许这有帮助。