0
return em.createQuery(
     "SELECT doc FROM TexyDoc doc 
       WHERE doc.origPath LIKE CONCAT('%', :1)")
    .setParameter(1, path)

leads to

QuerySyntaxException: expecting IDENT, found '1' near line 1, column 82 
[SELECT doc FROM cz.oz.web.model.TexyDoc doc 
   WHERE doc.origPath LIKE CONCAT('%', :1)]

Why? What should be the syntax like?

4

1 回答 1

0

这里的问题是你做 args 的方式。改为这样做:

LIKE CONCAT('%', :path)"

接着:

.setParameter("path", path);

命名参数更具可读性。

于 2013-01-30T05:52:07.530 回答