0

The following hibernate query fails:

select 1 as "{jsonprop:'string'}" from dual

with the following exception:

org.hibernate.QueryException: Space is not allowed after parameter prefix ':' [ select 1 as "{json:'string'}" from dual]

Is there no way to escape the colon character in Hibernate 4? Ive tried \: and :: but neither worked. Ive seen mention that this might have been corrected in the v3 parser, but its still failing - even though the colon is inside a constant.

The Shoe Shiner
  • 697
  • 4
  • 20

2 Answers2

0

I don't have a quick way to test this, but I believe '\:' is what you need.

select 1 as "{jsonprop\\:'string'}" from dual

See https://stackoverflow.com/a/11971764/3684299

If that doesn't work, where are you defining your query: in a named query file or within a String in code?

Community
  • 1
  • 1
0

If you're using hibernate 5+ i believe you can use '::' to escape ':'. see here

If you're using 4.x a solution i've used is to use like/ilike and the '_' character.

pstanton
  • 35,033
  • 24
  • 126
  • 168