Hibernate Native SQL
Hibernate provide option to execute native SQL queries through the use of SQLQuery object. Hibernate SQL Query is very handy when we have to execute database vendor specific queries that are not supported by Hibernate API. For example query hints or the CONNECT keyword in Oracle Database.
Considering the below entity relationship. We would be discussing the below points;
1 Creating Native queries with createNativeQuery
2 Use parameter binding in native SQL queries.
3 Adding scalars
4.1 Native Joins
4.2 Adding joins with entity mapping. This is for adding entity via eager loading
5 Iterating through the result set and constructing the Beans
5.1 Querying with Entity mapping
5.2 basic Result set mapping using @SqlResultSetMapping
5.3 Mapping Non-managed entities via result transformer
6 Using @NamedNativeQuery