src/common/dao/BaseDao.java

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。



package common.dao;

import java.sql.SQLException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import common.entity.Entity;

public abstract class BaseDao extends HibernateDaoSupport implements IDao {
	protected abstract Class getEntityClass();

	public Entity insert(Entity entity) throws DataAccessException {
		this.getHibernateTemplate().save(entity);
		return entity;
	}

	public Entity delete(int id) throws DataAccessException {
		Entity entity = this.load(id);
		this.getHibernateTemplate().delete(entity);
		return entity;

	}

	public Entity update(Entity entity) throws DataAccessException {
		this.getHibernateTemplate().update(entity);
		return entity;
	}

	public Entity load(int id) throws DataAccessException {
		return (Entity) this.getHibernateTemplate().load(this.getEntityClass(),
				id);
	}
	public Entity get(int id) throws DataAccessException {
		return (Entity) this.getHibernateTemplate().get(this.getEntityClass(),
				id);
	}
	public List loadAll() throws DataAccessException {
		return this.getHibernateTemplate().loadAll(this.getEntityClass());
	}

	public List queryList(final String className, final String where,
			final int start, final int length) throws DataAccessException {
		return this.getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session session)
后面还有 165 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。