• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

createNativeQuery causing SQL syntax error

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All

This took a bit to figure out so I thought I would share.



See that # - if you're using toplink you want the # for a named substitution BUT if you're using hibernate you want a :
and somefield is a string in the above - you don't need to wrap it in quotes. toplink at least will figure it out.

sheesh....that su...ed...and yes i know, i know, blah, blah, blah....don't use native queries...more blahs...
hope the above is helpful....

Amy
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parameters are meant to be indexed in JPA native SQL queries using the "?" marker.
 
reply
    Bookmark Topic Watch Topic
  • New Topic