Multiple choice technology web technology

Which statement is executing native query to fetch records from table?

  1. sess.createQuery("SELECT * FROM CATS").list();

  2. sess.createSQLQuery("FROM CATS").list();

  3. sess.createSQLQuery("SELECT * FROM CATS").list();

  4. sess.createSQLQuery("from CATS", com.animals.Cat.class).list();

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Native SQL queries in Hibernate are executed using createSQLQuery() method which accepts raw SQL strings. Option C uses the correct syntax. Option A uses HQL (createQLQuery), Option B uses incorrect SQL, and Option D incorrectly mixes HQL syntax with SQL.