br.com.arsmachina.dao.hibernate
Class BaseHibernateDAO<T,K extends Serializable>

java.lang.Object
  extended by br.com.arsmachina.dao.hibernate.BaseHibernateDAO<T,K>
Type Parameters:
T - the entity class related to this DAO.
K - the type of the field that represents the entity class' primary key.
Direct Known Subclasses:
ReadableDAOImpl, WriteableDAOImpl

public class BaseHibernateDAO<T,K extends Serializable>
extends Object

Superclass of both ReadableDAOImpl and WriteableDAOImpl.

Author:
Thiago H. de Paula Figueiredo

Constructor Summary
BaseHibernateDAO(Class<T> clasz, org.hibernate.SessionFactory sessionFactory)
          Constructor that takes a Class and a SessionFactory.
BaseHibernateDAO(org.hibernate.SessionFactory sessionFactory)
          Constructor that takes a Class and a SessionFactory.
 
Method Summary
protected  org.hibernate.metadata.ClassMetadata getClassMetadata()
          Returns the ClassMetadata for the corresponding entity class.
protected  Class<T> getEntityClass()
          Returns the entity class handled by this DAO.
protected  String getPrimaryKeyPropertyName()
          Returns the name of the id property.
protected  org.hibernate.classic.Session getSession()
          Returns a Session.
protected  org.hibernate.SessionFactory getSessionFactory()
          Returns this DAO's SessionFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseHibernateDAO

public BaseHibernateDAO(org.hibernate.SessionFactory sessionFactory)
Constructor that takes a Class and a SessionFactory.

Parameters:
clasz - a Class.
sessionFactory - a SessionFactory. It cannot be null.

BaseHibernateDAO

public BaseHibernateDAO(Class<T> clasz,
                        org.hibernate.SessionFactory sessionFactory)
Constructor that takes a Class and a SessionFactory.

Parameters:
clasz - a Class.
sessionFactory - a SessionFactory. It cannot be null.
Method Detail

getEntityClass

protected final Class<T> getEntityClass()
Returns the entity class handled by this DAO.

Returns:
a Class.

getSession

protected org.hibernate.classic.Session getSession()
Returns a Session. This implementation returns SessionFactory.getCurrentSession() and can be overriden if needed.

Returns:
a Session.

getSessionFactory

protected final org.hibernate.SessionFactory getSessionFactory()
Returns this DAO's SessionFactory.

Returns:
a SessionFactory.

getClassMetadata

protected final org.hibernate.metadata.ClassMetadata getClassMetadata()
Returns the ClassMetadata for the corresponding entity class.

Returns:
a ClassMetadata.

getPrimaryKeyPropertyName

protected String getPrimaryKeyPropertyName()
Returns the name of the id property.

Returns:
a String.


Copyright © 2008-2009 Thiago H. de Paula Figueiredo. All Rights Reserved.