我正在使用MariaDB与Java Sping Boot 。驱动程序是这样的:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.3.0</version>
</dependency>
字符串
JPA repository方法如下:
List<Plugin> findAllByPalpUrlStartingWith(
String palpUrl
);
型
当应用程序运行时,它会生成一个不正确的SQL:
select *
from remote_plugins p1_0
where p1_0.palp_url like 'test' escape '\';
型
这是不正确,因为引号字符被反斜杠转义,因此它是未闭合字符串。
我不知道ESCAPE应该做什么,MariaDB文档没有提到这一点,我只能说它显然在引用转义方面很糟糕。
我可以强制JPA为startingWith
用例生成正确的SQL子句吗?也许可以完全禁用这个ESCAPE?
1条答案
按热度按时间hxzsmxv21#
由于MariaDB实现了JDBC驱动程序,因此会自动添加转义。根据MariaDB文档,您可以使用不同的SQL_MODE禁用转义。
尝试将其添加到JDBC连接字符串中,如下所示:
字符串