3
我與一個註解Hibernate查詢工作,並收到以下異常@Query參數:Hibernate的註釋工作不正常
Caused by: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:81) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:87) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:444) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:416) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
at org.hibernate.ejb.QueryImpl.setParameter
這裏的代碼,導致了它:
@Query(value = "from MatchReport where match = ?1 and categoryCDList like '%?2%' or categoryCDList like '%ALL%'")
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
List<MatchReport> findByMatchAndUserType(Match match, String userType);
這是幸福不逃避單引號造成的?如果是這樣,我怎樣才能在註釋中轉義這些引號?我查找了文檔並且簡短了一些。
有此相同的問題 - 如果任何人有一個答案,這將是真棒 – izikandrw
什麼彈簧數據的JPA版? –