gpt4 book ai didi

java - org.springframework.dao.InvalidDataAccessApiUsageException : Parameter with that position [2] did not exist

转载 作者:行者123 更新时间:2023-11-29 15:50:04 24 4
gpt4 key购买 nike

我正在尝试运行 a. SpringBoot中的API程序,我在其中有一个查询。以前它显示了 parseException 错误,我已解决该错误,但现在出现了这个新错误。这个问题在其他查询中从未出现过,我不知道问题是什么。请帮忙。

@Query(value="SELECT * FROM tbl_abc WHERE UserId = ?1 AND EndTime != '' AND StartDate BETWEEN '?2' AND '?3' ORDER BY StartDate ASC,StartTime",nativeQuery = true)
List<abc> getabctLog(int userId, String fromdate1, String todate1);

我希望从表中获得查询中给出的条件的详细信息列表。但我收到了这个:

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter with that position [2] did not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [2] did not exist

最佳答案

我认为您的 StartDate 是 Date 类型,但您输入了一个字符串。您需要更改代码:

@Query(value="SELECT * FROM tbl_abc WHERE UserId = ?1 AND EndTime != '' AND StartDate BETWEEN '?2' AND '?3' ORDER BY StartDate ASC,StartTime",nativeQuery = true)
List<abc> getabctLog(int userId, Date fromdate1, Date todate1);

关于java - org.springframework.dao.InvalidDataAccessApiUsageException : Parameter with that position [2] did not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56811501/

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