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

java.lang.Object
  extended by br.com.arsmachina.dao.hibernate.BaseHibernateDAO<T,K>
      extended by br.com.arsmachina.dao.hibernate.WriteableDAOImpl<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.
All Implemented Interfaces:
br.com.arsmachina.dao.WriteableDAO<T,K>

public abstract class WriteableDAOImpl<T,K extends Serializable>
extends BaseHibernateDAO<T,K>
implements br.com.arsmachina.dao.WriteableDAO<T,K>

WriteableDAO implementation using Hibernate. All methods use BaseHibernateDAO.getSession() to get a Session.

Author:
Thiago H. de Paula Figueiredo

Constructor Summary
WriteableDAOImpl(Class<T> clasz, org.hibernate.SessionFactory sessionFactory)
          Constructor that takes a Class and a SessionFactory.
WriteableDAOImpl(org.hibernate.SessionFactory sessionFactory)
          Constructor that takes a Class and a SessionFactory.
 
Method Summary
 void delete(K id)
           
 void delete(T object)
           
 void evict(T object)
           
 boolean isPersistent(T object)
          Returns true if the primary key field (identifier) of the given object is not null.
 void save(T object)
           
 T update(T object)
           
 
Methods inherited from class br.com.arsmachina.dao.hibernate.BaseHibernateDAO
getClassMetadata, getEntityClass, getPrimaryKeyPropertyName, getSession, getSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteableDAOImpl

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

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

WriteableDAOImpl

public WriteableDAOImpl(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

delete

public void delete(K id)
Specified by:
delete in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>

delete

public void delete(T object)
Specified by:
delete in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>

evict

public void evict(T object)
Specified by:
evict in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>

save

public void save(T object)
Specified by:
save in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>

update

public T update(T object)
Specified by:
update in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>

isPersistent

public boolean isPersistent(T object)
Returns true if the primary key field (identifier) of the given object is not null. Its value is obtained via ClassMetadata.getIdentifier(Object, EntityMode).

Specified by:
isPersistent in interface br.com.arsmachina.dao.WriteableDAO<T,K extends Serializable>
Throws:
IllegalArgumentException - if object is null.
See Also:
WriteableDAO.isPersistent(java.lang.Object)


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