Skip to main content

Commonly asked Hibernate Interviews questions and answers

1) what is Hibernate?

         Hibernate is a popular java framework which allows a efficient Object Relation Mapping using configuration files in XML format. It is Handle the database without writing any complex queries.


2) what is ORM?
     

          Object Relational Mapping is the concepts of Hibernate framework which it used to map object and a database and provides a various API to perform a different types of operations on the database tables.  

3 )The usage of Configuration Interface in hibernate?

          Configuration interface of hibernate framework is used to configure hibernate. Mapping documents of hibernate are located using this interface


4)How do we create session factory in hibernate?
      Configuration config = new Configuration();
         SessionFactory sessions = config.buildSessionFactory();

5) What are POJOs and what’s their significance?

         POJOs( Plain Old Java Objects) are java beans with proper getter and setter methods for each and every properties.


           Use of POJOs instead of simple java classes results in an efficient and well constructed code.

                POJO is a objects which encapsulates business logic


6)What are the benefits of using Hibernate template?

  • Session closing is automated.
  • Interaction with hibernate session is simplified.
  • Exception handling will be handled automatically.


7)What the benefits are of hibernate over JDBC?

a. Hibernate can be used seamlessly with any type of database as its database independent while in case of JDBC, developer has to write database specific queries.

b. Using hibernate, developer doesn’t need to be an expert of writing complex queries as HQL simplifies query writing process while in case of JDBC, its job of developer to write and execute queries.(each and everytime we have to write the queries).

c. In case of hibernate, there is no need to create connection pools as hibernate does all connection handling automatically while in case of JDBC, connection pools need to be created and also must have to close the connection.

8) How can we reduce database write action times in Hibernate?

Hibernate provides dirty checking feature which can be used to reduce database write times. Dirty checking feature of hibernate updates only those fields which require a change while keeps others unchanged. By using the dirty checking features we can reduce the writing action into the database.

9) What’s the usage of callback interfaces in hibernate?

Callback interfaces of hibernate are useful in receiving event notifications from objects.

 For example, when an object is loaded or deleted, an event is generated and notification is sent using callback interfaces.











Comments

Popular posts from this blog

Commonly asked Top 26 Java Interview Questions

1.what is a transient variable? A transient variable is a variable that may not be serialized. If you don't want to serialize any objects then we have to use Transient Keyword. 2. Why do threads block on I/O? Threads block on i/o (that enters the waiting state) so that other threads may execute while the i/o Operation is performed. So your blocked thread of execution blocks only that: the thread of execution. 3. How are Observer and Observable used? Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects(refer 1.4). 4. What is synchronization and why is it important?                      With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Withou

All difference Question in java(common difference) (Collections)

1)Difference Between Interfaces And Abstract class? All the methods declared in the Interface are Abstract,where as abstract class must have atleast one abstract method and others may be concrete. In abstract class keyword abstract must be used for method, where as in Interface we need not use the keyword for methods. Abstract class must have Sub class, where as Interface can’t have sub classes.  An abstract class can extend only one class, where as an Interface can extend more than one. 2)Difference between Arrays and Vectors?             Because Vectors are dynamically-allocated, they offer a relatively memory-efficient way of handling lists whose size could change drastically. Arrays are fixed in size and it's wastage of memory problem. A Vector might be a good choice for such an arrangement. Moreover, Vectors have some useful member functions that make coding simpler. While in array is the bad choice of the arrangement and the code become more complex. Vecto

Decode of the image file from hibernate and struts

Create a java file for the decoding the image Image.java package com.img.action; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.imageio.ImageIO; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import com.img.dao.ConnectionDAO; import com.img.pojo.Film_TablePojo; import com.img.pojo.imagePojo; import com.opensymphony.xwork2.ActionSupport; public class Show extends ActionSupport { List<Object> values = new ArrayList<Object>();  public List<Object> getValues() { return values; } public void setValues(List<Object> values) { this.values = values; } /*HttpServletRequest request;     public void setServletRequest(HttpServletRequest