Is there any benefit of using @NamedQuery
over @NamedNativeQuery
in hibernate or vice verse.
I cant spot the exact difference or
in which context we should use @NamedQuery
over @NamedNativeQuery
Thanks in advance.
@NamedNativeQuery
lets you write a named SQL query, while @NamedQuery
lets you write a named HQL query (or JPQL).
In general, you should prefer to write HQL queries because then you can let Hibernate handle the intricacies of converting the HQL into the various SQL dialects. This will make your job much simpler when you choose to switch DBMS providers.