springboot jpa使用

package com.jxd.Boot.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.jxd.Boot.po.Student;

/**
* @author jinxudong
*
*/
public interface StudentDao extends JpaRepository<Student, Long> {
Student findByName(String studentName);

@Query(value = "sql", nativeQuery = true)
Student findByUid(String uid);

/**
* @Description (原生态sql)
* @return
*/
@Query(value = "select s.* from student s where 1=1 ", nativeQuery = true)
List<Student> selectStudent();

/**
* @Description (多条件查询)
* @param name
* @param age
* @return
*/
List<Student> findByNameAndAge(String name, Integer age);

List<Student> findByNameLike(String name);

/**
* @Description (模糊搜索按字段排序)
* @param name
* @return
*/
List<Student> findByNameLikeOrderByAge(String name);

/**
* @Description (按字段排序)
* @return
*/
List<Student> findByOrderByAgeDesc();

/**
* @Description (按字段统计)
* @param name
* @return
*/
long countByName(String name);


}

posted @ 2018-05-31 16:17  洞玄巅峰  阅读(145)  评论(0编辑  收藏  举报