Hibernate Questions1. What is Hibernate?     Hibernate is a powerful, high performance object/relational persistence and q...
7. What are the benefits does HibernateTemplate provide?The benefits of HibernateTemplate are :    • HibernateTemplate, a ...
Upcoming SlideShare
Loading in...5
×

Hibernate questions

167

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
167
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Hibernate questions"

  1. 1. Hibernate Questions1. 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 collections2.WHAT IS ORM ?ORM stands for Object/Relational mapping. It is the programmed and translucentperseverance of objects in a Java APPLICATION in to the tables of a relational database usingthe metadata that describes the mapping between the objects and the database. It works bytransforming the data from one representation to another.3.What are the different levels of ORM quality? There are four levels defined for ORM quality.  Pure relational  Light object mapping  Medium object mapping  FULL OBJECT MAPPING4. How will you configure Hibernate?The configuration files hibernate.cfg.xml (or hibernate.properties) and mapping files*.hbm.xml are used by the Configuration class to create (i.e. configure and bootstraphibernate) the SessionFactory, which in turn creates the Session instances. Sessioninstances are the primary interface for the persistence service." hibernate.cfg.xml (alternatively can use hibernate.properties): These two files are used toconfigure the hibernate sevice (connection driver class, connection URL, connectionusername, connection password, dialect etc). If both files are present in the classpath thenhibernate.cfg.xml file overrides the settings found in the hibernate.properties file." Mapping files (*.hbm.xml): These files are used to map persistent objects to a relationaldatabase. It is the best practice to store each object in an individual mapping file (i.emapping file per class) because storing large number of persistent classes into one mappingfile can be difficult to manage and maintain. The naming convention is to use the same nameas the persistent (POJO) class name. For example Account.class will have a mapping filenamed Account.hbm.xml. Alternatively hibernate annotations can be used as part of yourpersistent class code instead of the *.hbm.xml files.5. What are derived properties?The properties that are not mapped to a column, but calculated at runtime by evaluation ofan expression are called derived properties. The expression can be defined using theformula attribute of the element.6 Define HibernateTemplate?org.springframework.orm.hibernate.HibernateTemplate is a helper class which providesdifferent methods for querying/retrieving data from the database. It also converts checkedHibernateExceptions into unchecked DataAccessExceptions.
  2. 2. 7. What are the benefits does HibernateTemplate provide?The benefits of HibernateTemplate are : • HibernateTemplate, a Spring Template class simplifies interactions with Hibernate Session. • Common functions are simplified to single method calls. • Sessions are automatically closed. • Exceptions are automatically caught and converted to runtime exceptions.8 . What is the difference between sorted and ordered collection in hibernate?sorted collection vs. order collection :- sorted collection order collectionA sorted collection is sorting a collection byutilizing the sorting features provided by the Order collection is sorting a collection byJava collections framework. The sorting specifying the order-by clause for sorting thisoccurs in the memory of JVM which running collection when retrieval.Hibernate, after the data being read fromdatabase using java comparator.If your collection is not large, it will be more If your collection is very large, it will be moreefficient way to sort it. efficient way to sort it .9. What are the Collection types in Hibernate ? • Bag • Set • List • Array • Map10. What is Hibernate proxy?The proxy attribute enables lazy initialization of persistent instances of the class. Hibernatewill initially return CGLIB proxies which implement the named interface. The actual persistentobject will be loaded when a method of the proxy is invoked

×