使用JPA,只需指定方法簽名即可完成多種查詢組合。請諮詢http://docs.spring.io/spring-data/jpa/docs/1.4.3.RELEASE/reference/html/jpa.repositories.html
在你的資料庫界面,您可以
List<Person> findAll(); // this is standard
List<Person> findById(String id); // looking person that have specific Id
List<Person> findByNameLike(String name); // you can put the name "foo%"
如果你想分頁和排序...
Page<Person> findByNameLike(String name, PageRequest pageRequest);
你使用它像
int page = 0; // first page
int size = 10; // show 10 result max per page
Page personPage = repo.findByNameLike("A%", new PageRequest(page,size,Sort.Direction.ASC, "birthDate")); // pagination for person with name, page 0, 10 item per page, and sorted by the person.birthDate.
好運
我在這裏沒有看到問題.... – ChiefTwoPencils
@ChiefTwoPencils我已更新/編輯問題 –