In the Hibernate we can express a query in SQL, using createSQLQuery() and let Hibernate manage the mapping from result sets to objects. we can use any time call session.connection() and use the JDBC Connection directly. When we use the Hibernate API, you must enclose SQL aliases in braces:
List cats = session.createSQLQuery("SELECT {student.*} FROM STUDENT {student} WHERE ROWNUM<10")
.addEntity("student", Student.class)
.list();
List student = session.createSQLQuery("SELECT {student}.ID AS {student.id}, {student}.SEX AS {student.sex}, " + "{student}.MATE AS {student.mate}, {student}.SUBCLASS AS {student.class}, ... " + "FROM STUDENT {student} WHERE ROWNUM<10")
.addEntity("student", Student.class)
.list()
SQL queries can contain named and positional parameters, just like Hibernate queries.