SpringData 方法定义规范

简单条件查询

  • 查询方法必须以find|read|get开头,
  • 涉及条件查询时,条件的属性同条件之间用关键字连接,条件属性首字母大写
  • 支持属性级联查询,当当前类又符合条件的属性时,优先使用当前类属性,而不使用级联属性;若需要使用级联属性 属性之间使用_连接

  • 支持的关键字如下
    这里写图片描述

这里写图片描述

  • 实列展示
//where name like ?% and id < ?
    List<Person> getByNameStartingWithAndIdLessThan(String Name, Integer id);

    // where email in(?,?,?) or birth <?;
    List<Person> getByEmailInOrBrithLessThan(List<String> email ,Date date); 

    //where  a.id > ?    级联属性的id(新的实体) 
    List<Person> getByAddressIdGreaterThan(Integer id);

PS: 进行相关测试即可 ,可参照上一节测试例子

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章