I'm trying to run a native query through JPA that uses a ':' character. The particular instance is using a MySQL user variable in the query:
SELECT foo, bar, baz,
@rownum:= if (@id = foo, @rownum+1, 1) as rownum,
@id := foo as rep_id
FROM
foo_table
ORDER BY
foo,
bar desc
The JPA code:
Query q = getEntityManager().createNativeQuery(query, SomeClass.class);
return q.getResultList();
However, this gives me an exception about not being allowed to follow a ':' with a space. I've tried escaping them with backslashes, I've tried escaping them by doubling them up. Is there any way to actually do this, or am I SOL?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…