gpt4 book ai didi

java - 在 java spring boot 中使用 Mysql 函数

转载 作者:行者123 更新时间:2023-12-01 00:08:47 24 4
gpt4 key购买 nike

我的存储库中的自定义查询有点问题:

@Query("select v from Visit v where YEARWEEK('date') = YEARWEEK(curdate())")

在 YEARWEEK('date') 左括号之前显示错误:

<expression>, <operator>, AND, GROUP, HAVING, IS, OR or ORDER expected, got '('

最佳答案

你有两个选择:

对于 HQL,您需要以下内容:

@Query("select * from Visit v where YEARWEEK('v.date') = YEARWEEK(curdate())")

你也可以有本地查询,在这种情况下你需要遵循(不是 Spring 应用程序的最佳方式,但可以用于某些情况)

@Query(value = "select * from Visit where YEARWEEK('date') = YEARWEEK(curdate())", nativeQuery = true)

关于java - 在 java spring boot 中使用 Mysql 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48539809/

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