Hibernate - Interview Questions and Answers for 'Hibernate' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Hibernate - Interview Questions and Answers for 'Hibernate' - 92 question(s) found - Order By Rating

next 30
 Q1. Can you explain integration between Spring and Hibernate ?Hibernate
 This question was recently asked at 'HCL Technologies'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Spring framework  Hibernate Orm     Asked in 1 Companies


 Q2. Difference between merge and update in hibernateHibernate
 This question was recently asked at 'Nucleus Software'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q3. what annotation do in background in hibernate ?Hibernate
 This question was recently asked at 'Cdac Pune'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q4. Why do we use Hibernate ?Hibernate
 This question was recently asked at 'NIIT'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q5. What is the concept of hibernate versioning ?Hibernate
 This question was recently asked at 'Tata Consultancy (TCS)'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate versioning     Asked in 1 Companies


 Q6. Explain different inheritance mapping strategies with JPA / Hibernate.Hibernate
Ans. table per hierarchy
table per concrete class
table per sub class

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate mapping  hibernate associations     Asked in 4 Companies


 Q7. Explain Hibernate caching mechanismHibernate
Ans. Every fresh session having its own cache memory, Caching is a mechanism for storing the loaded objects into cache memory. The advantage of cache mechanism is, whenever again we want to load the same object from the database then instead of hitting the database once again, it loads from the local cache memory only, so that the no. of round trips between an application and a database server got decreased. It means caching mechanism increases the performance of the application.

In hibernate we have two levels of caching

First Level Cache [ or ] Session Cache
Second Level Cache [ or ] Session Factory Cache [ or ] JVM Level Cache

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 23 Companies


 Q8. Explain hibernate associations.Hibernate
 This question was recently asked at 'Ray Business Technologies'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q9. What is Entity in hibernate?Hibernate
 This question was recently asked at 'naresh i technologies'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q10. Which jar files need to be included for using Hibernate ?Hibernate
Ans. hibernate-orm
hibernate-validator
hibernate-ogm
hibernate-search

or you can download hibernate core with all dependencies.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate jar files   hibernate     Asked in 1 Companies


 Q11. What is the use of sql dialect ?Hibernate
Ans. Dialect means "the variant of a language".

Similarly in case of SQL Dialect we specify what dialect of SQL to be generated keeping in mind of underlying database.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     sql dialect  hibernate   hibernate     Asked in 2 Companies


 Q12. If your application has multiple databases, how many changes you have to made in Hibernate? Hibernate
Ans. If you have mulitple Databases you just need to add multiple configuration files and create the corresponding SessionFactory object.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q13. What is the difference between save() and persist() in hibernate ?Hibernate
 This question was recently asked at 'IBM'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q14. Difference between Eager and Lazy loading in hibernate ?Hibernate
Ans. Lazy Loading is loading of entities on demand when subclass is called, while Eager loading is loading of all the sub entity at the start only.

Eager loading is fast as all sub entities are already present, but its heavy(takes more memory)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q15. What is the use of second level cache in Hibernate ?Hibernate
Ans. Second level cache is shared between sessions. Hibernate by default uses first level cache. Second level cache need to be configurd to use.
There are several second level cache e.g eh cache,jboss cache etc.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q16. What is difference between Spring jdbc template and Hibernate ?Hibernate
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Spring JDBC vs Hibernate  Spring JDBC   Hibernate


 Q17. Can you write the code for implementing the one to many (student -> courses) relationship in hibernate?Hibernate
Ans. @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "student_id")
private Set countries;

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q18. What is meant by dirty object checking in hibernate ?Hibernate
Ans. Dirty Checking is one of the features of hibernate. In dirty checking, hibernate automatically detects whether an object is modified (or) not and need to be updated. As long as the object is in persistent state i.e., bound to a particular Session, Hibernate monitors any changes to the objects and executes sql.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     dirty checking in hibernate     Asked in 1 Companies


 Q19. Explain Hibernate Validation ?Hibernate
 This question was recently asked at 'Sofi'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate  hibernate validation     Asked in 1 Companies


 Q20. What is the difference between JDBC, Hibernate and ODBC ?Database
 This question was recently asked at 'Oracle Argentina'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jdbc  odbc  hibernate  jdbc vc odbc  jdbc vs hibernate     Asked in 1 Companies


 Q21. What could be the possible cause for following exception ?

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):

What could be the way to fix it ?
Hibernate
Ans. This looks like the case for optimistic locking wherein hibernate suspects that the information in table was updated by some other transaction after the entity was loaded by current transaction.

One way is to have synchronized entity state and don't detach the entity. Other could be to merge the entity with the table record rather than just directly persisting the entity.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     StaleObjectStateException  Optimistic locking


 Q22. What is ConstraintViolationException in Hibernate ?Hibernate
Ans. The exception is thrown when a database constraint is violated.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     ConstraintViolationException


 Q23. What are the core interfaces in Hibernate?Hibernate
Ans. Session,SessionFactory,Configuration,Transaction,query and Criteria

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     core interfaces of Hibernate     Asked in 1 Companies        frequent

Try 1 Question(s) Test


 Q24. What is the use of Hibernate session.evict()?Hibernate
Ans. It is used to dissociate / disconnect a particular object from the session.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate session evict  hibernate evict


 Q25. What is the use of Hibernate session.clear() ?Hibernate
Ans. It is used to clear the session and is used to dissociate disconnect all the objects from the session.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate session clear


 Q26. What is the difference between session.clear and session.evict ?Hibernate
Ans. session.clear clears all the objects from session whereas session.evict is used for evicting a particular entity.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate session clear  hibernate evict

Try 2 Question(s) Test


 Q27. How can we make sure that Hibernate doesn't update the entity changes to DB or how to keep the entity detached ?Hibernate
Ans. If it's only a read only transaction, we can wrap the get / load call in read only transaction.

If we want it to be application wide, we an set the flush mode accordingly or else we can evict the entity object to remove them from session.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     

Try 2 Question(s) Test


 Q28. Does Hibernate synchronize entity with the database automatically i.e any change to entity gets updated in DB ?Hibernate
Ans. Yes, the feature is there but can be override with changing the Flush Mode.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


 Q29. Is it advisable to keep session or transaction open for long time just to avoid LazyInitializationException ?Hibernate
Ans. No. It's a resource and performance overhead.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     LazyInitializationException  Lazy Loading


 Q30. What was the worst problem you faced while working with Hibernate ?Hibernate
Ans. Lazy Initialization exceptions

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: