31.How do you invoke Stored Procedures?
<sql-query name="selectAllEmployees_SP" callable="true">
 <return alias="emp" class="employee">
   <return-property name="empid" column="EMP_ID"/>       
   <return-property name="name" column="EMP_NAME"/>       
   <return-property name="address" column="EMP_ADDRESS"/>
    { ? = call selectAllEmployees() }
 </return>
</sql-query>


32.Explain Criteria API
The interface org.hibernate.Criteria represents a query against a particular persistent class. The Session is a factory for Criteria instances. Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens where there is a variable number of conditions to be placed upon the result set.
Example :
List employees = session.createCriteria(Employee.class)
                         .add(Restrictions.like("name", "a%") )
                         .add(Restrictions.like("address", "Boston"))
                         .addOrder(Order.asc("name") )
                         .list();


33.What’s the difference between load() and get()?


load() 

get() 

Only use the load() method if you are sure that the object exists. 

If you are not sure that the object exists, then use one of the get() methods. 

load() method will throw an exception if the unique id is not found in the database. 

get() method will return null if the unique id is not found in the database. 

load() just returns a proxy by default and database won’t be hit until the proxy is first invoked.  

get() will hit the database immediately. 


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


35.Define cascade and inverse option in one-many mapping?
cascade - enable operations to cascade to child entities.
cascade="all|none|save-update|delete|all-delete-orphan"

inverse - mark this collection as the "inverse" end of a bidirectional association.
inverse="true|false"
Essentially "inverse" indicates which end of a relationship should be ignored, so when persisting a parent who has a collection of children, should you ask the parent for its list of children, or ask the children who the parents are?


36.Define HibernateTemplate?
org.springframework.orm.hibernate.HibernateTemplate is a helper class which provides different methods for querying/retrieving data from the database. It also converts checked HibernateExceptions into unchecked DataAccessExceptions.