spring boot中使用关键字搜索的问题
来源:互联网 发布:数据存储计量单位 编辑:程序博客网 时间:2024/06/11 06:50
最近在用spring boot框架做一个项目。做到使用关键字搜索的时候出现以下报错:
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter with that position [1] did not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [1] did not exist
我的repository类如下:(关于@RepositoryRestResource可以参考http://www.jianshu.com/p/3423fa97d185)
import java.util.List;import org.springframework.data.domain.Page;import org.springframework.data.domain.Pageable;import org.springframework.data.jpa.repository.Query;import org.springframework.data.repository.PagingAndSortingRepository;import org.springframework.data.repository.query.Param;import org.springframework.data.rest.core.annotation.RepositoryRestResource;import org.springframework.transaction.annotation.Transactional;import edu.dgut.supervision.domain.VDuchadian;@RepositoryRestResource(collectionResourceRel = "VDuchadian", path = "vDuchadian")public interface DuchadianRepository extends PagingAndSortingRepository<VDuchadian, String>{//String代表主键的数据类型List<VDuchadian> findByProjectNo(@Param("projectNo") String projectNo);@Transactional(readOnly=true)@Query("select u from VDuchadian u where u.number = ?1")VDuchadian findByNumber(@Param("number") String number);@Transactional(readOnly=true)@Query("select u from VDuchadian u where u.name like '%?1%'")Page<VDuchadian> findByKeyWords(@Param("keywords") String keywords,Pageable pageable);}
其中findByKeyWords是我写的模糊查询的接口
经过多次测试发现将模糊查询语句中like后面的单引号去掉就行了,但是sql语句中like后面是要加单引号的,可能这是spring boot中的一种设计吧,后面有待深入研究
阅读全文
0 0
- spring boot中使用关键字搜索的问题
- spring boot(三):Spring Boot中Redis的使用
- spring boot(三):Spring Boot中Redis的使用
- Spring Boot系列(三):Spring Boot中Redis的使用
- spring boot(三):Spring Boot中Redis的使用
- spring boot(三):Spring Boot中Redis的使用
- 转载:Spring Boot (十一):Spring boot中mongodb的使用
- spring boot中自动创建表不支持的关键字
- spring boot运行中遇到的问题
- spring boot 使用jsp 的一些问题
- Spring Boot中使用自定义的properties
- 11. Spring Boot中Redis的使用
- spring boot中定时任务的使用
- Spring boot中mongodb的使用
- Spring Boot中MyBatis的使用
- spring boot 中redis的使用
- Spring boot 中缓存的使用
- Spring Boot中Redis的使用
- 如果maven项目没有导入的提示,可能是没有依赖
- OOAD Lab4实验文档
- C++在1秒内生成不同的随机数
- Java的语法规范
- YUV 中 YV21图像格式的旋转
- spring boot中使用关键字搜索的问题
- 攒够了失望才离开?检测你是否适合现在工作的10个指标
- VC6创建COM组件,Qt调用例子
- thinkphp实现多种方式往数据库内添加数据
- 程序员开发23种模式
- D_D系统构建-文件分布及说明
- SeekBar和RatingBar
- js批量动态设置样式
- 死锁