views:

49

answers:

1

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", "%PATHNAME%");

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.

A: 

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

stjowa