Yes, it does. Hibernate provides the createSQLQuery()
method to let a developer call the native SQL statement directly and returns a Query object.
Consider the example where you want to get employee data with the full name “Hibernate
”. We don't want to use HQL-based features, instead, we want to write our own SQL queries. In this case, the code would be:
Query query = session.createSQLQuery( "select * from interviewbit_employee ibe where ibe.fullName = :fullName")
.addEntity(InterviewBitEmployee.class)
.setParameter("fullName", "Hibernate"); //named parameters
List result = query.list();
Alternatively, native queries can also be supported when using NamedQueries
.