当前位置:网站首页>记录一下使用JPA时遇到的坑
记录一下使用JPA时遇到的坑
2022-06-12 11:08:00 【YOSHINO_Cream】
前言
这几天做实习任务,发下来的项目ORM框架使用的是JPA,之前完全没有接触过,不过也能照葫芦画瓢写一下,这过程中碰到了一点坑,特此记录一下,后期如果再碰到还会继续更新。
环境
项目比较老 Spring-boot版本是1.5.6对应的spring-boot-jpa版本也是1.5.6.RELEASE
坑1
该方法传了两个参数 都是String 然后运行时报错
JPA-style positional param was not an integral ordinal;
说是没有按照顺序使用JPA风格的参数
SQL部分语句是这样的
如图所使,在箭头指向的方向传了参数,这样会报错。之后上网上查了查,有人说是参数后面必须跟一个空格,否则会不被识别。照做了之后能够正常运行。
正确写法如上
坑2
** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near **
相同的SQL语句,直接扔数据库进行查询能够正常通过,但通过JPA进行查询就会报这个错误。
我观察了一下这个SQL语句,发现where关键字没有像其他关键字一样用黄色来凸显出来。推测又是空格的原因 于是在前面加了个空格
这下能够被识别出来了,进行测试,正常通过了。
总结
其实踩到这两个坑归根揭底都是SQL解析的问题,当不加空格时,在进行SQL解析时会把关键字和别的字段连一块解析,而长sql导致了我们很难在第一时间发现这个问题。总之尽量少写长SQL
边栏推荐
- 对网络库协程的思考——读brpc有感
- 重量级代理缓存服务器Squid
- selenium使用代理IP
- FPGA key experiment
- PHP specifies the number of people to distribute the specified amount equally at random (scaling method)
- Handwritten common interview questions
- The solution of Lenovo notebook ThinkPad t440 WiFi dropping all the time
- Malicious code analysis practice - lab03-03 Exe basic dynamic analysis
- B+ 树的简单认识
- Grid layout
猜你喜欢

Reading mysql45 lecture - self summary (part)

Flex layout

人脸识别pip 安装dlib库失败

Malicious code analysis practice - lab03-02 DLL analysis

Pseudo static setting of access database in win2008 R2 iis7.5

Malicious code analysis practice - use IDA pro to analyze lab05-01 dll

Grid layout

M-Arch(番外11)GD32L233评测-PWM驱动有源蜂鸣器

InfoQ geek media's 15th anniversary solicitation |position:fixed virtual button cannot take effect after being triggered. Problem analysis and Solution Exploration

Common methods of string class
随机推荐
重量级代理缓存服务器Squid
Malicious code analysis practice - lab03-02 DLL analysis
XML Parsing Error: mismatched tag. Expected
ReentrantLock源码分析
^33 variable promotion and function promotion interview questions
JS open common application market
Using the echart plug-in to dynamically refresh charts in uview/uni-app
Vite Basics
On 3dsc theory and application of 3D shape context feature
Sendmail Dovecot 邮件服务器
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
Assign a specified amount to a specified number of people at random
元宇宙链游与传统游戏的区别
Clickhouse column basic data type description
MySQL performance test (slow query log)
DS18B20数字温度计 (一) 电气特性, 供电和接线方式
Reverse analysis of Huawei housekeeper software [transfer]
程序分析与优化 - 6 循环优化
(37) How bee uses different data source instances at the same time
Zabbix 监控之LLD