13.What role does the Session interface play in Hibernate?
The main runtime interface between a Java application and Hibernate The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.
The main function of the Session is to offer create, read and delete operations for instances of mapped entity classes. Instances may exist in one of three states:

transient: never persistent, not associated with any Session
persistent: associated with a unique Session
detached: previously persistent, not associated with any Session

Session session = sessionFactory.openSession();
Session interface role:


14.What role does the SessionFactory interface play in Hibernate?

SessionFactorys are immutable. The behaviour of a SessionFactory is controlled by properties supplied at configuration time. These properties are defined on Environment.
The application obtains Session instances from a SessionFactory. There is typically a single SessionFactory for the whole application—created during application initialization. The SessionFactory caches generate SQL statements and other mapping metadata that Hibernate uses at runtime. It also holds cached data that has been read in one unit of work and may be reused in a future unit of work
Implementors must be threadsafe.
SessionFactory sessionFactory = configuration.buildSessionFactory();

15.What are the most common ways to specify the  Hibernate configuration properties?
The most common methods of Hibernate configuration are:

        By using setProperty(-) method of org.hibernate.cfg.Configuration.

16.How do you map Java Objects with Database tables?

Example :
<hibernate-mapping>
  <class name="com.durgasoft.EmployeeBean"  table="EMPLOYEE">
     <id name=”eid” colume=”id”/>
   <property name="ename" column="NAME" length="255"
     not-null="true"  type="java.lang.String"/>
   <property name="address" column="ADDR" length="255"
     not-null="true"  type="java.lang.String"/>
 </class>
</hibernate-mapping>

17.How do you define sequence generated primary key algorithm in hibernate?
By using <id>, <generator> tags we can configure the primary key and primary key generation algorithm.
Example:-
<id name="userid" column="USER_ID" type="java.lang.Long">
   <generator class="sequence">
     <param name="table">SEQ_NAME</param>
   <generator>
</id>

18.What is component mapping in Hibernate?