package .dao.hibernate;
import java.util.List;
import .dao.hibernate.BaseDaoHibernate;
import .;
import .dao.Dao;
import org.springframework.orm.ObjectRetrievalFailureException;
public class DaoHibernate extends BaseDaoHibernate implements Dao {
/**
* @see .dao.Dao#gets(.)
*/
public List gets(final ) {
return getHibernateTemplate().find("from ");
/* Remove the line above and uncomment this code block if you want
to use Hibernate's Query by Example API.
if ( == null) {
return getHibernateTemplate().find("from ");
} else {
// filter on properties set in the
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
Example ex = Example.create().ignoreCase().enableLike(MatchMode.ANYWHERE);
return session.createCriteria(.class).add(ex).list();
}
};
return (List) getHibernateTemplate().execute(callback);
}*/
}
/**
* @see .dao.Dao#get( )
*/
public get(final ) {
= () getHibernateTemplate().get(.class, );
if ( == null) {
log.warn("uh oh, with '" + + "' not found...");
throw new ObjectRetrievalFailureException(.class, );
}
return ;
}
/**
* @see .dao.Dao#save( )
*/
public void save(final ) {
getHibernateTemplate().saveOrUpdate();
}
/**
* @see .dao.Dao#remove( )
*/
public void remove(final ) {
getHibernateTemplate().delete(get());
}
}