Hibernate Interview Questions And Answers

Hibernate's primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types). Hibernate also provides data query and retrieval facilities. Hibernate generates the SQL calls and relieves the developer from manual result set handling and object conversion, keeping the application portable to all SQL databases, with database portability delivered at very little performance overhead.

Hibernate provides transparent persistence for Plain Old Java Objects (POJOs). The only strict requirement for a persistent class is a no-argument constructor, not compulsorily public. (Proper behavior in some applications also requires special attention to the equals() and hashCode() methods.)

Hibernate provides a dirty checking feature that avoids unnecessary database write actions by performing SQL updates only on the modified fields of persistent objects.

Hibernate can be used both in standalone Java applications and in Java EE applications using servlets or EJB session beans.



<< Previous                Next >>

 

11. What are the different levels of ORM quality?

 There are four levels defined for ORM quality.
i. Pure relational
ii. Light object mapping
iii. Medium object mapping
iv. Full object mapping


12. What are the different methods of identifying an object?

 There are three methods by which an object can be identified.
i. Object identity ?Objects are identical if they reside in the same memory location
in the JVM. This can be checked by using the = = operator.
ii. Object equality ? Objects are equal if they have the same value, as defined by the
equals( ) method. Classes that don?t explicitly override this method inherit the
implementation defined by java.lang.Object, which compares object identity.
iii. Database identity ? Objects stored in a relational database are identical if they
represent the same row or, equivalently, share the same table and primary key value.


13. What are the Extension interfaces that are there in hibernate?

 There are many extension interfaces provided by hibernate.
 ProxyFactory interface - used to create proxies
 ConnectionProvider interface ? used for JDBC connection management
 TransactionFactory interface ? Used for transaction management
 Transaction interface ? Used for transaction management
 TransactionManagementLookup interface ? Used in transaction management.
 Cahce interface ? provides caching techniques and strategies
 CacheProvider interface ? same as Cache interface
 ClassPersister interface ? provides ORM strategies
 IdentifierGenerator interface ? used for primary key generation
 Dialect abstract class ? provides SQL support


14. What do you create a SessionFactory?

Configuration cfg = new Configuration();
cfg.addResource("myinstance/MyConfig.hbm.xml");
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();
First, we need to create an instance of Configuration and use that instance to refer to the
location of the configuration file. After configuring this instance is used to create the
SessionFactory by calling the method buildSessionFactory().


15. What does an ORM solution comprises of?

 1? It should have an API for performing basic CRUD (Create, Read, Update, Delete)
operations on objects of persistent classes
2? Should have a language or an API for specifying queries that refer to the classes
and the properties of classes
3? An ability for specifying mapping metadata
4? It should have a technique for ORM implementation to interact with transactional
objects to perform dirty checking, lazy association fetching, and other optimization
functions


Your Ad Here

16. What does hibernate.properties file consist of?

 This is a property file that should be placed in application class path. So when the
Configuration object is created, hibernate is first initialized. At this moment the
application will automatically detect and read this hibernate.properties file.
hibernate.connection.datasource = java:/comp/env/jdbc/AuctionDB
hibernate.transaction.factory_class =
net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class =
net.sf.hibernate.transaction.JBossTransactionManagerLookup
hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect


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









Everything should be included under  tag. This is the main tag for
an xml mapping document.


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


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


20. What is a pure relational ORM?

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


Your Ad Here

<< Previous                Next >>

 
Databases Questions and Answers
 
DB2 Interview Questions and Answers
IMS Interview Questions and Answers
MYSQL Interview Questions and Answers
Oracle Interview Questions and Answers
PL/SQL Interview Questions And Answers
Quel Interview Questions and Answers
SQL Interview Questions and Answers

 
 
.NET Interview Questions and Answers
 
ASP Interview Questions and Answers
C# Interview Questions and Answers
Visual Basic Interview Questions and Answers
 
J2EE Interview Questions and Answers
 
Enterprise Java Beans (EJB) Interview Questions And Answers
Hibernate Interview Questions And Answers
Jave Messaging Service (JMS) Interview Questions And Answers
Jave Server Faces (JSF) Interview Questions And Answers
Java Server Pages (JSP) Interview Questions And Answers
Servlets Interview Questions And Answers
Spring Framework Interview Questions And Answers
Struts Framework Interview Questions And Answers
 
JAVA Interview Questions and Answers
 
Core Java Interview Questions and Answers
Java Platform, Micro Edition (Java ME) Interview Questions And Answers
JAVA GUI Interview Questions and Answers
Java Performance Tuning Interview Questions And Answers
JUnit Interview Questions And Answers
Remote Method Invocation (RMI) Interview Questions And Answers
Unified Modeling Language (UML) Interview Questions And Answers
 
Java Application Server Interview Questions And Answers
 
Tomcat Application Server Interview Questions And Answers
WebLogic Application Server Interview Questions And Answers
 
Mainframe Interview Questions and Answers
 
CICS Interview Questions and Answers
COBOL Interview Questions and Answers
IMS Interview Questions and Answers
JCL Interview Questions and Answers
REXX Interview Questions and Answers
TELON Interview Questions and Answers
VSAM Interview Questions and Answers
 
Object Oriented Language Questions and Answers
 
C Interview Questions and Answers
C++ Interview Questions and Answers
Eiffel Interview Questions and Answers
J2EE Interview Questions and Answers
JAVA Interview Questions and Answers
Sather Interview Questions and Answers
Small talk Interview Questions and Answers
 
Operation Systems Interview Questions and Answers
 
MS DOS Interview Questions and Answers
Unix OS Interview Questions and Answers
Windows Interview Questions and Answers
 
Scripting languages Interview Questions and Answers
 
Java Script Interview Questions and Answers
Practical Extraction and Reporting Language Interview Questions and Answers
PHP Interview Questions and Answers
VBScript Interview Questions and Answers
 
UserInterfaces Questions and Answers
 
Foxit Interview Questions and Answers
Glade Interview Questions and Answers
Tweak Interview Questions and Answers
 
WEB Technologies Questions and Answers
 
AJAX Interview Questions and Answers
HTML Interview Questions and Answers
WML Interview Questions and Answers
XML Interview Questions and Answers
 
Interview Tips And Some Common Questions
 
Behavioral Interview Questions And Answers


Your Ad Here