Hibernate

1.What is ORM ?
ORM stands for object/relational mapping. ORM is the automated persistence of objects in a Java application to the tables in a relational database.

2.What does ORM consists of ?
An ORM solution consists of the following four pieces:
  • API for performing basic CRUD operations
  • API to express queries refering to classes
  • Facilities to specify metadata
  • Optimization facilities : dirty checking,lazy associations fetching 

3.What are the ORM levels ?
The ORM levels are:
  • Pure relational (stored procedure.)
  • Light objects mapping (JDBC)
  • Medium object mapping
  • Full object Mapping (composition,inheritance, polymorphism, persistence by reachability)

4.What is Hibernate?
Hibernate is a pure Java object-relational mapping (ORM) and persistence framework that allows you to map plain old Java objects to relational database tables using (XML) configuration files.Its purpose is to relieve the developer from a significant amount of relational data persistence-related programming tasks.
  
5.What is the difference between and merge and update ?
Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. 
6. What is the difference between sorted and ordered collection in hibernate?
sorted collection vs. order collection :-
sorted collection order collection 
A sorted collection is sorting a collection by utilizing the sorting features provided by the Java collections framework. The sorting occurs in the memory of JVM which running Hibernate, after the data being read from database using java comparator. Order collection is sorting a collection by specifying the order-by clause for sorting this collection when retrieval. 
If your collection is not large, it will be more efficient way to sort it. If your collection is very large, it will be more efficient way to sort it . 

7. What are the states of object in hibernate?

There are 3 states of object (instance) in hibernate.

Transient: The object is in transient state if it is just created but has no primary key (identifier) and not associated with session.
Persistent: The object is in persistent state if session is open, and you just saved the instance in the database or retrieved the instance from the database.
Detached: The object is in detached state if session is closed. After detached state, object comes to persistent state if you call lock() or update() method.


8. What are the collection types in Hibernate?

There are five collection types in hibernate used for one-to-many relationship mappings.

Bag
Set
List
Array
Map




No comments:

Post a Comment