【问题标题】:org.hibernate.QueryParameterException:Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 1org.hibernate.QueryParameterException:超出声明序数参数数量的位置。请记住,序数参数是基于 1 的!职位:1
【发布时间】:2021-12-08 11:37:44
【问题描述】:

我想执行我的选择查询,

@Query(value=" select * from data o where o.id = :id ",nativeQuery = true)

public List findList(Integer id);

得到非法参数异常,

位置超出了声明的序数参数的数量。请记住,序数参数是基于 1 的!位置:1

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
  • 异常在标题中突出显示。将来会即兴创作我的编辑。得到了问题的答案。 @Param 不见了。

标签: hibernate


【解决方案1】:

我错过了@Param,

@Query(value=" select * from data o where o.id = :id ",nativeQuery = true) public List findList(@Param("id") Integer id);

添加上面突出显示的代码,问题得到解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-18
    • 2012-10-16
    • 2015-07-18
    • 1970-01-01
    • 2016-03-09
    • 1970-01-01
    • 2017-01-06
    • 1970-01-01
    相关资源
    最近更新 更多