JOBSEEKER?

Java Hibernate Interview Questions

Practice for Java Hibernate interviews by solving TestDome questions. Our interview questions are used by more than 7,000 companies and 450,000 individual test takers.

Jobseekers: Certify Your Knowledge

Take a Certification Test

Companies: Use Our Tests for Screening

Buy a Pack Of Candidates

Need to practice your Hibernate skills for an upcoming job interview? Try solving these Hibernate interview questions that test your ability to solve common Hibernate problems such as annotating classes for persistence, writing HQL and Criteria queries, or using transactions. Each question covers one Hibernate topic like annotations, HQL, or transactions. We’ll provide feedback on your answers, and you can use a hint if you get stuck.

These Hibernate interview questions are examples of real tasks used by employers to screen candidates for a variety of job roles, such as Java developers, web developers, back-end developers, and others that need working knowledge of Hibernate.

1. Pet DAO

HQL
   
Easy 

The PetDAO class is used for various database operations on the Pet entity.

Finish the findNamedPetsBySpecies method so that it returns all pets of the appropriate species. The method should not return any Pets whose name field is null. The method accepts a Hibernate Session object that it should use to make the query.

For example, if the Pets table contains:

id  name   species
--------------------
0   Lady   Dog
1   Max    Cat
2   null   Camel

calling findNamedPetsBySpecies with "Cat" as the species, should return a list that contains a pet named "Max" with the id 1.

Solve Question

2. Stock

Annotations Entity Type
   
Easy 

The Stock class is used to represent a snapshot of a company's stock in the database.

Add appropriate annotations to the class, so that Hibernate maps it in the following way:

  • The id field should be the primary key, which should be generated when the object is saved.
  • The companyName field should be mapped to the "company_name" column in the database.
  • The price field should be mapped to the "price" column in the database, it should never be null.
Solve Question

If you feel ready, take one of our timed public Java Hibernate Interview Questions tests:
Java

Java and Hibernate Online Test (Easy / Hard)

Java, Hibernate, and Spring Framework Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.
Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers