Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Generic Dao is a Java package which allows a developer to skip writing
DAOs for their persistence objects when they are using Spring and/or Hibernate.
The package was originally created by Aaron Zeckoski for the Evaluation System
project but was repackaged to make it distributable by request. It is used in the
RSF framework (http://www2.caret.cam.ac.uk/rsfwiki/). Note about the BeanUtils
provided dependency: BeanUtils is not required if you are not using it in your
project. Note about the Hibernate provided dependency: Hibernate is not required
if you are not using it in your project.
/******************************************************************************
* HibernateGeneralGenericDao.java - created by [email protected]
*
* Copyright (c) 2006, 2007, 2008
* Licensed under the Apache License, Version 2
*
* A copy of the Apache License, Version 2 has been included in this
* distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Contributors:
* Aaron Zeckoski ([email protected]) - primary
*
*****************************************************************************/
package org.sakaiproject.genericdao.hibernate;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.hibernate.criterion.DetachedCriteria;
import org.sakaiproject.genericdao.api.GeneralGenericDao;
/**
* A Hibernate (http://hibernate.org/) based implementation of GeneralGenericDao
* which can be extended to add more specialized DAO methods.
*
* See the overview for installation/usage tips.
*
* @author Aaron Zeckoski ([email protected])
*/
public class HibernateGeneralGenericDao extends HibernateBasicGenericDao implements GeneralGenericDao {
// public void deleteSet(Set entities) {
// checkEntitySet(entities);
// // TODO - reattach non-persistent objects
// getHibernateTemplate().deleteAll(entities);
// }
@SuppressWarnings("unchecked")
public List findAll(Class entityClass, int firstResult, int maxResults) {
DetachedCriteria criteria = DetachedCriteria.forClass(checkClass(entityClass));
List items = (List) getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
return items;
}
// OVERRIDES
/**
* MUST override this method
*/
protected int baseCountAll(Class type) {
return count(START_QUERY + " " + checkClass(type).getName());
}
/**
* MUST override this method
*/
protected int baseSaveSet(Class> type, Set entities) {
for (T t : entities) {
getHibernateTemplate().saveOrUpdate(t);
}
return entities.size();
}
/**
* MUST override this method
*/
protected int baseDeleteSet(Class type, Serializable[] ids) {
Set