开发者

Incorrect usage of STR() function in HQL

With this HQL query:

SELECT DISTINCT fs FROM FileStatus fs WHERE UPPER(STR(fs.filePath)) LIKE :FILE_PATH

I get:

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)

and with my FILE_PATH named parameter, I have the following in a map:

paramMap.put("FILE_PATH", "%PATHNAM开发者_开发问答E%");

I have no idea why this is happening. To make things more confusing (or maybe it will help everyone out), if I use a number in the file path, like paramMap.put("FILE_PATH", "%23%"); it works just fine.

The parameter map is passed into the DAO.read() method along with the query. Hibernate handles the rest. Something like this:

fileStatusDao.read(query, parameterMap);

Thanks in advance for the help.


The issue ended up being that I was using STR() function on an attribute that was already a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜