0

Hi I am a newbie using persistence API, and have also read few posts related to the same and got a very few understanding between these two. the below post really helped me clear my concepts for @NamedQuery What is a named query? I now wanted to learn all the important key differences between NamedQuery and NamedNativeQuery, and which one is preferred most while dealing with JPA-QL, and performance wise.

Thanks!

Community
  • 1
  • 1
AKIWEB
  • 19,008
  • 67
  • 180
  • 294

1 Answers1

2

A native query isn't JPQL. A regular query is converted by the persistence provider into something the underlying persistence system understands (such as SQL SELECT, or a NoSQL retrieval). A native query, while not portable, is written directly in the native language of the store so that you can use special features (like PostgreSQL's IP address manipulation) at the cost of portability.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
  • Thanks @chrylis for correcting me and giving me this information. could you please also guide which one is usually preferred to use on performance basis? and is there any other difference too that I need to keep in mind? thanks in advance – AKIWEB Sep 11 '13 at 22:55
  • @akiiddweeber Always use the portable versions of anything unless you really, really need some specific capability. Always start by writing clearly and portably, and only go back to optimize for performance if you have measured a serious performance problem. – chrylis -cautiouslyoptimistic- Sep 11 '13 at 22:56