贫民窟里的程序高手

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

这个与上一篇的基本相同,需要修改的只有Dao层的文件:

TablesDao.java

package com.shinho.dao;

import org.springframework.data.jpa.repository.Query;
import  org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import com.shinho.entity.Tables;

@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface TablesDao extends CrudRepository<Tables, Integer> {
    
    @Query(value="select count(*) from props",nativeQuery=true)
    int getcount();
}

这里有个学问,就是访问的地址,是这样一个规则,比如现在看到的这个getcount的方法:

http://localhost:7088/people/search/getcount

蛋疼!

还有,这个东西是Spring Data JPA,一定要看官网,不要看网上的野文!

官网地址:http://projects.spring.io/spring-data-jpa/

posted on 2018-04-25 15:53  贫民窟里的程序高手  阅读(256)  评论(0)    收藏  举报