Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

escaping SQL keywords in hibernate

 
Chandra shekar M
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a hibernate foruma like this.
<formula>
(select listagg(size,',') WITHIN group (order by size) from (select distinct(size) from a where id = 10 ))
</formula>

Hibernate is not identify WITHIN as keyword instead it prefixs it with table a alias to avoid this i wrote it like
<formula>
(select listagg(size,',') 'WITHIN' group (order by size) from (select distinct(size) from a where id = 10 ))
</formula>

Hibernate will not prefix the table alias instead it will be 'WITHIN' in the final query and SQL fails saying missing WITHIN keyword. How to pass WITHIN
to final sql?

Thanks
Chandra
 
Richard Borchard
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Old question, but I've posted the fix here:

http://stackoverflow.com/a/36828139/5676608

Simply, you need to register the "within" keyword with Hibernate:



And ensure the dialect is registered in your persistence.xml:



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic