What are the different options to retrieve an object from database in Hibernate?

In Hibernate, we can use one of the following options to retrieve objects from database:

  • Identifier: We can use load() or get() method and pass the identifier like primary key to fetch an object from database.
  • HQL: We can create a HQL query and get the object after executing the query.
  • Criteria API: We can use Criteria API to create the search conditions for getting the objects from database.
  • Native SQL: We can write native SQL query for a database and just execute it to get the data we want and convert it into desired object.
Read the full book at www.amazon.com
Posted in Hibernate, Hibernate Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*