The largest Interview Solution Library on the web


Hibernate Tutorials/
« Previous | 1 | 2 | 3 | Next »
There are number of methods provided by the Session interface but I'm going to list down few important methods only, which we will use in this tutorial. You can check Hibernate documentation for a complete list of methods associated with Session and SessionFactory.

S.N.Session Methods and Description
1Transaction beginTransaction()
Begin a unit of work and return the associated Transaction object.
2void cancelQuery()
Cancel the execution of the current query.
3void clear()
Completely clear the session.
4Connection close()
End the session by releasing the JDBC connection and cleaning up.
5Criteria createCriteria(Class persistentClass)
Create a new Criteria instance, for the given entity class, or a superclass of an entity class.
6Criteria createCriteria(String entityName)
Create a new Criteria instance, for the given entity name.
7Serializable getIdentifier(Object object)
Return the identifier value of the given entity as associated with this session.
8Query createFilter(Object collection, String queryString)
Create a new instance of Query for the given collection and filter string.
9Query createQuery(String queryString)
Create a new instance of Query for the given HQL query string.
10SQLQuery createSQLQuery(String queryString)
Create a new instance of SQLQuery for the given SQL query string.
11void delete(Object object)
Remove a persistent instance from the datastore.
12void delete(String entityName, Object object)
Remove a persistent instance from the datastore.
13Session get(String entityName, Serializable id)
Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.
14SessionFactory getSessionFactory()
Get the session factory which created this session.
15void refresh(Object object)
Re-read the state of the given instance from the underlying database.
16Transaction getTransaction()
Get the Transaction instance associated with this session.
17boolean isConnected()
Check if the session is currently connected.
18boolean isDirty()
Does this session contain any changes which must be synchronized with the database?
19boolean isOpen()
Check if the session is still open.
20Serializable save(Object object)
Persist the given transient instance, first assigning a generated identifier.
21void saveOrUpdate(Object object)
Either save(Object) or update(Object) the given instance.
22void update(Object object)
Update the persistent instance with the identifier of the given detached instance.
23void update(String entityName, Object object)
Update the persistent instance with the identifier of the given detached instance.
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com