⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 surveydaoimpl.java

📁 简单的网上调查系统。采用Spring+Hibernate方式设计架构。
💻 JAVA
字号:
package com.mySurvey.dao.impl;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.mySurvey.bean.Survey;
import com.mySurvey.dao.SurveyDAO;

public class SurveyDAOImpl extends HibernateDaoSupport  implements SurveyDAO{
	private SessionFactory sessionFactory;
	private String hql = "from Survey u where u.id = ?";
	private String hql1 = "from Survey u";
	//查询多笔调查
    public List queryList() {
		List list = new ArrayList();
		list = this.getHibernateTemplate().find(hql1);
		return list;
    }
	//查询单笔调查
    public Survey query(Survey survey) {
    	Survey survey1 = null;
    	//如果查询结果为空
		if (this.getHibernateTemplate().find(hql, survey.getId()) == null ) {
			survey1 = null;
		} else {
			//不为空时,取第一笔
			survey1 = (Survey)(this.getHibernateTemplate().find(hql, survey.getId()).get(0));
		}
		return survey1;
    }
    //新增调查
	public void insert(Survey survey) {
		this.getHibernateTemplate().save(survey);
	}
	//修改调查
	public void update(Survey survey) {
		this.getHibernateTemplate().update(survey);
	}
	//删除调查
	public void delete(Survey survey) {
		this.getHibernateTemplate().delete(survey);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -