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

   



Interview Questions and Answers - Order By Newest

   
 Q71. 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


 Q72. 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


 Q73. 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


 Q74. 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


 Q75. 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


 Q76. 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


 Q77. 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


 Q78. 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


 Q79. 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


 Q80. 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


 Q81. 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


 Q82. 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


 Q83. 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


 Q84. 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


 Q85. 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


 Q86. 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


 Q87. 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


 Q88. 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


 Q89. 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


 Q90. 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


 Q91. 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


 Q92. 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


 Q93. What is Lazy Initialization in Hibernate ?Hibernate
a. Feature to load the dependencies from Cache
b. Feature to load all objects and relationships in advance before they can be used
c. Feature to not load dependencies and relationship in advance and load when required
d. Feature to not load the dependencies and relationships at all

Ans.c. Feature to not load dependencies and relationship in advance and load when required

 Q94. Which of the following is not the benefit of Lazy Initialization in Hibernate ?Hibernate
a. Laod When required provides better performance
b. Object stays lighter
c. Less number of Database calls
d. Less load on Database

Ans.c. Less number of Database calls

 Q95. Which of the following is not true for Hibernate Cache ?Hibernate
a. First level cache is enabled by default
b. First level Cache is Session specific
c. First level cache is considered global
d. First level Cache came with Hibernate 1.0

Ans.c. First level cache is considered global

 Q96. Which of the following is not an Hibernate AnnotationHibernate
a. @Id
b. @JoinTable
c. @ManyToMany
d. @Autowired

Ans.d. @Autowired

 Q97. Which of the following Design pattern has been used with Hibernate Criteria ?Hibernate
a. Filter
b. Prototype
c. Builder
d. Observer

Ans.a. Filter

 Q98. Which of following is not core interface of Hibernate ?Hibernate
a. Session
b. Transaction
c. SessionFactory
d. TransactionFactory

Ans.d. TransactionFactory

 Q99. Which of the following session method is used to disassociate / disconnect all objects from the sessionHibernate
a. Clear
b. Evict
c. Close
d. Merge

Ans.a. Clear

 Q100. Which of the following session method is used to disassociate / disconnect a particular object / entity from the sessionHibernate
a. Clear
b. Evict
c. Close
d. Merge

Ans.b. Evict

previous 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: