10:13 pm - Friday March 22, 2019

Hibernate Interview Question11

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

1. What are Extension interfaces?

When the built-in functionalities provided by hibernate is not sufficient enough, it provides a way so that user can include other interfaces and implement those interfaces for user desire functionality. These interfaces are called as Extension interfaces.

2. What are Callback interfaces?

These interfaces are used in the application to receive a notification when some object events occur. Like when an object is loaded, saved or deleted. There is no need to implement callbacks in hibernate applications, but they’re useful for implementing certain kinds of generic functionality.

3. What the Core interfaces are of hibernate framework?

There are many benefits from these. Out of which the following are the most important one.

  • Session Interface -This is the primary interface used by hibernate applications. The instances of this interface are lightweight and are inexpensive to create and destroy. Hibernate sessions are not thread safe.

  • SessionFactory Interface -This is a factory that delivers the session objects to hibernate application. Generally there will be a single SessionFactory for the whole application and it will be shared among all the application threads.

  • Configuration Interface -This interface is used to configure and bootstrap hibernate. The instance of this interface is used by the application in order to specify the location of hibernate specific mapping documents.

  • Transaction Interface -This is an optional interface but the above three interfaces are mandatory in each and every application. This interface abstracts the code from any kind of transaction implementations such as JDBC transaction, JTA transaction.

  • Query and Criteria Interface -This interface allows the user to perform queries and also control the flow of the query execution.

4. What is a hibernate XML mapping document and how does it look like?

In order to make most of the things work in hibernate, usually the information is provided in an xml document. This document is called as xml mapping document. The document defines, among other things, how properties of the user defined persistence classes’map to the columns of the relative tables in database.

<?xml version=”1.0″?>

<!DOCTYPE hibernate-mapping PUBLIC “



<class name=”sample.MyPersistanceClass” table=”MyPersitaceTable”>

<id name=”id” column=”MyPerId”>



<property name=”text” column=”Persistance_message”/>

<many-to-one name=”nxtPer” cascade=”all” column=”NxtPerId”/>



5. How does hibernate code looks like?

Session session = getSessionFactory().openSession();

Transaction tx = session.beginTransaction();

MyPersistanceClass mpc = new MyPersistanceClass (“Sample App”);




6. What are the benefits of ORM and Hibernate?

There are many benefits from these. Out of which the following are the most important one.

1. Productivity -Hibernate reduces the burden of developer by providing much of the functionality and let the developer to concentrate on business logic.

2. Maintainability -As hibernate provides most of the functionality, the LOC for the application will be reduced and it is easy to maintain. By automated object/relational persistence, it even reduces the LOC.

3. Performance -Hand-coded persistence provided greater performance than the automated one. But this is not true all the times. But in hibernate, it provides more optimization that works all the time thereby increasing the performance. If it is automated persistence then it still increases the performance.

Vendor independence -Irrespective of the different types of databases

7. What is meant by full object mapping?

Full object mapping supports sophisticated object modeling: composition, inheritance, polymorphism and persistence. The persistence layer implements transparent persistence; persistent classes do not inherit any special base class or have to implement a special interface. Efficient fetching strategies and caching strategies are implemented transparently to the application.

8. What is a meant by medium object mapping?

The application is designed around an object model. The SQL code is generated at build time. And the associations between objects are supported by the persistence mechanism, and queries are specified using an object-oriented expression language. This is best suited for medium-sized applications with some complex transactions. Used when the mapping exceeds 25 different database products at a time.

9. What is a meant by light object mapping?

The entities are represented as classes that are mapped manually to the relational tables. The code is hidden from the business logic using specific design patterns. This approach is successful for applications with a less number of entities, or applications with common, metadata-driven data models. This approach is most known to all.

10. What is a pure relational ORM?

The entire application, including the user interface, is designed around the relational model and SQL-based relational operations.

 PARTS : >  1   2   3    4   5   6   7   8   9  10  11  12

Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply