Hibernate專案報錯could not locate named parameter [xxx]]
阿新 • • 發佈:2018-11-11
十月 26, 2018 3:12:06 上午 org.apache.catalina.core.StandardWrapperValve invoke 嚴重: Servlet.service() for servlet [springMVC] in context with path [/qjgl] threw exception [Request processing failed; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [userLogin]] with root cause org.hibernate.QueryParameterException: could not locate named parameter [userLogin] at org.hibernate.engine.query.spi.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:131) at org.hibernate.engine.query.spi.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:148) 。。。
原因:
1、可能是我們的引數設定有問題,例如:佔位符使用錯誤
query.setParameter(name, "123");
正確用法:
query.setParameter("name", "123");
2、如果使用的是hibernate或者其他框架的話,可能是配置檔案的掃描路徑沒配好(苦思冥想一點一點終於找到這個錯誤!!!!)
例如:目錄如下
我們寫掃描路徑的時候就應該寫成
<value>cn.hbu.qjgl.**.entity</value>