spring data jpa 内部封装了引用了 hibernate 的接口。
使用时,实际上使用的是 hibernate 的相关方法, 自定义查询也是按照 hibernate 进行的
/** * 整合 jpa 的接口 */ public interface TeacherRepository extends JpaRepository<Teacher, Integer> { /** * 自定义查询方法 * 根据主键查询 * * @param id 主键 * @return 教师对象 */ @Query(value = "SELECT t FROM Teacher t WHERE t.id=:id") public Teacher getTeacherById(@Param("id") Integer id);