Native SQL Queries
About
Characteristics
Feature
Description
Syntax Structure
Basic Syntax Example
String sql = "SELECT * FROM Employee WHERE department = :dept";
Query query = entityManager.createNativeQuery(sql);
query.setParameter("dept", "Sales");
List<Object[]> result = query.getResultList();Example with Native Query and Mapping to Entity
Examples
Prerequisites
1. Basic SELECT Query
2. JOIN Query
3. Aggregations
4. Update Query
5. Delete Query
6. Using SQL Functions
7. Subqueries
8. Batch Operations (Insert/Update/Delete)
How Native SQL Queries Compare with JPQL and Criteria API ?
Feature
Native SQL
JPQL
Criteria API
Last updated