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

 

21. What is Attribute Oriented Programming?

 XDoclet has brought the concept of attribute-oriented programming to Java. Until JDK
1.5, the Java language had no support for annotations; now XDoclet uses the Javadoc tag
format (@attribute) to specify class-, field-, or method-level metadata attributes. These
attributes are used to generate hibernate mapping file automatically when the application
is built. This kind of programming that works on attributes is called as Attribute Oriented
Programming.


22. What is component mapping in hibernate?

 A component is a contained object that is persisted as a value type ,not an entity reference.eg)
public class person{
private Name name;
public Name getName(){ return name;}
public void setName(Name name){this.name=name;}
.....
}
public class Name
{chat initial;
String first;
String last;
public char getInitial(){return initial;}
public void setInitial(char initial){this.initial=initial;}
.......//first,last
}
Now 'Name' may be persited to the component of 'person'
in hbm:
 
    

  

     

 

  
  
  
 
 
 
The person table would have the columns pid, birthday, initial, first and last.


23. What is database persistence? How well it is implemented in Hibernate

Preserving the data inside a database is database persistence. Persistence is once of the fundamental concepts of application development.

There are many alternatives to implement persistence. Object/relational mapping (ORM) is the technique that Hibernate tool uses to persist the data. By using ORM tool like Hibernate, you get advantages like low SQL coding (improved productivity), easy to maintain the system and also leads to better performance.


24. What is Hibernate proxy?

Proxies are created dynamically by sub classing your object at runtime. The subclass has all the methods of the parent, and when any of the methods are accessed, the proxy loads up the real object from the DB and calls the method for you


25. What is Hibernate?

 Hibernate is a powerful, high performance object/relational persistence and query service.
This lets the users to develop persistent classes following object-oriented principles such
as association, inheritance, polymorphism, composition, and collections.


Your Ad Here

26. What is HQL?

 HQL stands for Hibernate Query Language. Hibernate allows the user to express queries
in its own portable SQL extension and this is called as HQL. It also allows the user to
express in native SQL.


27. what is lazy fetching in hibernate?

There are two types of Loading in application. Eager loading and Lazy
loading. In eager loading we will fetch all the values from the Persistent storage and cache it. It will make serious performance issues. We use lazy loading to avoid that scenario.
Lazy setting decides whether to load child objects while loading the Parent Object. You need to do this setting respective hibernate mapping file of the parent class.Lazy = true (means not to load child) ( In the terms of database its primary key-foreign key relationship).
By default the lazy loading of the child objects is true. This make sure that the child objects are not loaded unless they are explicitly invoked in the application by calling getChild() method on parent. In this case hibernate issues a fresh database call to load the child when getChild() is actually called on the Parent object. But in some cases you do need to load the child objects when parent is loaded. Just make the lazy=false and hibernate will load the child when parent is loaded from the database
But Sometimes it doesn't work properly, it doesn't load the child objects for the parent .and second problem is that if you have condition like ....
Employee Table -1-----n-> Emp_Dept Table<-n------1- Department Table
And you have many to many relationship between them, then by specifying lazy="false" for both the parent object(Employee And Department) hibernate try to get all the child for this parent and for this child. Now this child becomes the parent and hibernate will try to get the entire child for this parent. This process may continue. This results in performance issue.
So U has to take care while writing the mapping files in case of many-to-many relationships.


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


29. What is meant by Method chaining?

 Method chaining is a programming technique that is supported by many hibernate
interfaces. This is less readable when compared to actual java code. And it is not
mandatory to use this format. Look how a SessionFactory is created when we use method
chaining.
SessionFactory sessions = new Configuration()
.addResource("myinstance/MyConfig.hbm.xml")
.setProperties( System.getProperties() )
.buildSessionFactory();


30. What is object/relational mapping metadata?

 ORM tools require a metadata format for the application to specify the mapping between
classes and tables, properties and columns, associations and foreign keys, Java types and
SQL types. This information is called the object/relational mapping metadata. It defines
the transformation between the different data type systems and relationship
representations.


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