gpt4 book ai didi

java - 使用spring data jpa点燃使用语法IN

转载 作者:行者123 更新时间:2023-12-01 19:16:44 27 4
gpt4 key购买 nike

当我将 JPA 与 IN 一起使用时,会导致一些问题,我该如何解决?我对表达式 IN 感到困惑吗?[*]。谢谢

ignite:2.7.6
spring jpa:ignite-spring-data_2.0
spring boot:2.0.9.RELEASE
h2:1.4.197

jpa方法:List findByShipVisitIdIsIn(List ShipVisitIdList);或 findByShipVisitIdIn。

第一个方法“findByArrivedTimeGreaterThanEqualAndArrivedTimeLessThanEqual”工作正常

@RepositoryConfig(cacheName = "BerthplanShipVisitCache")
public interface BerthplanShipVisitRepository extends IgniteRepository<BerthplanShipVisit, String>,
HdShipIdRepository<BerthplanShipVisit, String> {

List<BerthplanShipVisit> findByArrivedTimeGreaterThanEqualAndArrivedTimeLessThanEqual(Timestamp start, Timestamp end);

List<BerthplanShipVisit> findByShipVisitIdIsIn(List<String> shipVisitIdList);

}

SQL是由ignite-spring-data插件自动生成的,我猜是ignite-spring-datah2之间出了问题>

问题轨迹:

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT ""BerthplanShipVisitCache"".""BerthplanShipVisit""._KEY, ""BerthplanShipVisitCache"".""BerthplanShipVisit""._VAL FROM ""BerthplanShipVisit"" WHERE ((""BerthplanShipVisit"".""shipVisitId"" IN ?[*]))"; expected "("; SQL statement:
SELECT "BerthplanShipVisitCache"."BerthplanShipVisit"._KEY, "BerthplanShipVisitCache"."BerthplanShipVisit"._VAL FROM "BerthplanShipVisit" WHERE (("BerthplanShipVisit"."shipVisitId" IN ?)) [42001-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.getSyntaxError(DbException.java:217)
at org.h2.command.Parser.getSyntaxError(Parser.java:555)
at org.h2.command.Parser.read(Parser.java:3518)
at org.h2.command.Parser.readCondition(Parser.java:2433)
at org.h2.command.Parser.readAnd(Parser.java:2342)
at org.h2.command.Parser.readExpression(Parser.java:2334)
at org.h2.command.Parser.readTerm(Parser.java:3252)
at org.h2.command.Parser.readFactor(Parser.java:2587)
at org.h2.command.Parser.readSum(Parser.java:2574)
at org.h2.command.Parser.readConcat(Parser.java:2544)
at org.h2.command.Parser.readCondition(Parser.java:2370)
at org.h2.command.Parser.readAnd(Parser.java:2342)
at org.h2.command.Parser.readExpression(Parser.java:2334)
at org.h2.command.Parser.readTerm(Parser.java:3252)
at org.h2.command.Parser.readFactor(Parser.java:2587)
at org.h2.command.Parser.readSum(Parser.java:2574)
at org.h2.command.Parser.readConcat(Parser.java:2544)
at org.h2.command.Parser.readCondition(Parser.java:2370)
at org.h2.command.Parser.readAnd(Parser.java:2342)
at org.h2.command.Parser.readExpression(Parser.java:2334)
at org.h2.command.Parser.parseSelectSimple(Parser.java:2291)
at org.h2.command.Parser.parseSelectSub(Parser.java:2133)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1946)
at org.h2.command.Parser.parseSelect(Parser.java:1919)
at org.h2.command.Parser.parsePrepared(Parser.java:463)
at org.h2.command.Parser.parse(Parser.java:335)
at org.h2.command.Parser.parse(Parser.java:311)
at org.h2.command.Parser.prepareCommand(Parser.java:278)
at org.h2.engine.Session.prepareLocal(Session.java:611)
at org.h2.engine.Session.prepareCommand(Session.java:549)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:694)
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepare0(IgniteH2Indexing.java:539)
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:509)
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:476)
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatementAndCaches(IgniteH2Indexing.java:2635)
... 89 common frames omitted

最佳答案

最后,我编辑了源代码org.apache.ignite.springdata20.repository.query.IgniteRepositoryQuery的prepareQuery方法。其中,处理“IN?”到 'IN (?,?)' ,参数也变平。看来没问题。

关于java - 使用spring data jpa点燃使用语法IN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59408621/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com