首页>代码>spring+spring mvc+spring jpa+velocity开发b2c多用户商城项目,功能比较完善,有后台管理系统>/shopping/src/com/shopping/core/base/GenericDAO.java
package com.shopping.core.base; import java.io.Serializable; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import com.shopping.core.dao.IGenericDAO; public class GenericDAO<T> implements IGenericDAO<T> { protected Class<T> entityClass; @Autowired @Qualifier("genericEntityDao") private GenericEntityDao geDao; public Class<T> getEntityClass() { return this.entityClass; } public void setEntityClass(Class<T> entityClass) { this.entityClass = entityClass; } public GenericEntityDao getGeDao() { return this.geDao; } public void setGeDao(GenericEntityDao geDao) { this.geDao = geDao; } public GenericDAO() { this.entityClass = ((Class)((java.lang.reflect.ParameterizedType)getClass() .getGenericSuperclass()).getActualTypeArguments()[0]); } public GenericDAO(Class<T> type) { this.entityClass = type; } public int batchUpdate(String jpql, Object[] params) { return this.geDao.batchUpdate(jpql, params); } public List executeNamedQuery(String queryName, Object[] params, int begin, int max) { return this.geDao.executeNamedQuery(queryName, params, begin, max); } public List executeNativeNamedQuery(String nnq) { return this.geDao.executeNativeNamedQuery(nnq); } public List executeNativeQuery(String nnq, Object[] params, int begin, int max) { return this.geDao.executeNativeQuery(nnq, params, begin, max); } public int executeNativeSQL(String nnq) { return this.geDao.executeNativeSQL(nnq); } public List find(String query, Map params, int begin, int max) { return getGeDao() .find(this.entityClass, query, params, begin, max); } public void flush() { this.geDao.flush(); } public T get(Serializable id) { return (T) getGeDao().get(this.entityClass, id);//.get(this.entityClass, id); } public T getBy(String propertyName, Object value) { return (T) getGeDao().getBy(this.entityClass, propertyName, value); } public List query(String query, Map params, int begin, int max) { return getGeDao().query(query, params, begin, max); } public void remove(Serializable id) { getGeDao().remove(this.entityClass, id); } public void save(Object newInstance) { getGeDao().save(newInstance); } public void update(Object transientObject) { getGeDao().update(transientObject); } }

zolscy LV24
2024年11月28日
杨豫川 LV12
2024年3月14日
SDLFJL LV6
2023年8月16日
testuser1234567 LV24
2022年6月15日
oulingqiao LV13
2022年6月8日
wanglinddad LV55
2022年4月10日
evagsd LV6
2022年1月3日
sanshao526 LV12
2021年5月30日
有一种心情叫痛心 LV8
2021年4月16日
ewan007 LV30
2021年3月30日