package xxx;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class CommonDAOImpl extends HibernateDaoSupport {
@SuppressWarnings("unchecked") public <T> List<T> findAll(Class<T> entityclass) { //String name = entity.getClass().getName(); String hql = "from "+entityclass.getName()+" as aaa order by aaa.id desc"; return this.getHibernateTemplate().find(hql); }
@SuppressWarnings("unchecked") public <T> T findById(Class<T> entityClass, Integer id) { return (T) this.getHibernateTemplate().get(entityClass, id); }
public <T> void remove(T entity) { this.getHibernateTemplate().delete(entity); }
public <T> void sava(T entity) { this.getHibernateTemplate().save(entity); }
public <T> void update(T entity) { this.getHibernateTemplate().update(entity); }
}
|