【发布时间】:2016-09-13 12:58:57
【问题描述】:
我是 spring-boot 的新手,并且在构建我的项目方面一直在稳步取得进展,但我已经到了需要执行特定查询而不是 spring 构建的查询的地步。
这是我的@Query 的样子:
@Query("select top 1 * from 'table name' where 'column' like 'value' and message like 'value' order by 'column' desc")
由于它与工作相关,我不得不替换我们的数据库特定信息,但我认为你们仍然应该能够了解我正在尝试做什么。我的老板想要这个查询,因为如果没有这样的格式,我们会返回很多结果,我们只想要最近的 - 因此是前 1 个和 order by。
我看到的错误是“ or AS expected, got '1'”,到目前为止,我还没有在 Google 上找到任何东西。
我在这里做错了什么?
【问题讨论】:
-
@NeilStockton - 我更新了我的查询看起来更像 jpql 格式
code@Query(value = "select gl from table gl where gl.column1 like ?1 and gl.column2 = 'stuff ' order by gl.column desc") 现在它说它找不到表名。我遵循了here的例子。 -
好的,我会尝试这条路线,看看会发生什么。为了记录-停止大喊大叫。我很清楚这是我第一次使用这个框架。
标签: java spring-boot spring-data-jpa