springDataJpa——spectification查询
一、环境搭建
springDataJpa的环境搭建在上篇已经讲到,这篇中所使用的entity、Dao与层下面这个链接一致,这里不再赘述。springDataJpa环境搭建
二、使用测试
package com.xsl.test;
import com.xsl.dao.UserDao;
import com.xsl.entity.UserEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4C