In addition to HQL, Hibernate lets us load persistent objects with native SQL queries. Although using native SQL doesn't seem useful, you may prefer to use native SQL in some situations. For example, you may need to utilize database-specific features which are not supported by HQL. Another situation is when you want to call a stored procedure. Moreover, you may use native SQL when you are migrating from a legacy JDBC-based data tier to Hibernate and need to use SQL in the application. In these cases, either you must use native SQL, or you may prefer to continue working with SQL.
Hibernate provides the
org.hibernate.SQLQuery interface to work with SQL queries. To use it, pass the SQL query expression as a
String argument to ...