Interview questions on Database + Hibernate

Neeru K Singh
1 min readFeb 18, 2023

--

  1. How do you prevent SQL injection attacks?
  2. What is the difference between Non-Repeatable Read and Phantom Read? — click here
  3. What is difference between WHERE and HAVING clause?
  4. What are transactions? What is ACID?
  5. Is Hibernate using pessimistic or optimistic locking?
  6. What is default Isolation level in MYSQL ? Ans- The default isolation level for InnoDB is REPEATABLE READ( Mysql 8 version)
  7. How to properly handle two threads updating the same row in a database ? — click here
  8. Difference between truncate, delete and drop clause in SQL?
  9. What are window functions? how they work?
  10. What is indexing? Types of indexing?
  11. How does the query engine execute the query?
  12. Types of execution Engine ? — click here
  13. Pessimistic vs Optimistic Locking?
  14. What is 2PC ?
  15. What are Transaction Isolation levels ?- click here
  16. When is it better to use plain SQL instead of ORM?
  17. Difference between sorted and ordered collection?
  18. How second level cache works?
  19. What are the Anomalies in DBMS? — click here
  20. What is difference between save() and persist()?
  21. What is difference between Hibernate and MyBatis?
  22. What is N+1 error in Hibernate?
  23. What are the two types of Locking in Hibernate?
  24. What are different type of Caching in Hibernate and how to enable them in your application?
  25. How to have composite Key in a class in Hibernate?
  26. Difference between save() vs saveOrUpdate(), get() vs load(), save() vs persist(), merge() vs update()?
  27. Different type of Mapping in Hibernate and how to enable them?
  28. What are the different types of persistent Entity?
  29. What is Criterion query in hibernate?

--

--