shitioptiondaoimpl.java

来自「网上调查系统主要有管理员指定调查」· Java 代码 · 共 52 行

JAVA
52
字号
package com.myExam.dao.impl;
import java.util.ArrayList;
import java.util.List;

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

import com.myExam.bean.ShitiOption;
import com.myExam.dao.ShitiOptionDAO;
public class ShitiOptionDAOImpl extends HibernateDaoSupport implements ShitiOptionDAO{
	private SessionFactory sessionFactory;
	private String hql = "from ShitiOption u where u.id = ?";
	private String hql2 = "from ShitiOption u where u.shitiId = ?";
//	查询多笔试题项目
    public List queryListByShitiId(int typeId) {
		List list = new ArrayList();
		list = this.getHibernateTemplate().find(hql2, typeId);
		return list;
    }
	private String hql1 = "from ShitiOption u ";
//	查询多笔试题项目
    public List queryList() {
		List list = new ArrayList();
		list = this.getHibernateTemplate().find(hql1);
		return list;
    }
	//查询试题项目
    public ShitiOption query(int id) {
    	ShitiOption shitiOption = null;
    	//如果查询结果为空
		if (this.getHibernateTemplate().find(hql, id) == null ) {
			shitiOption = null;
		} else {
			//不为空时,取第一笔
			shitiOption = (ShitiOption)(this.getHibernateTemplate().find(hql, id).get(0));
		}
		return shitiOption;
    }
	//新增试题项目
	public void insert(ShitiOption shitiOption) {
		this.getHibernateTemplate().save(shitiOption);
	}
	//修改试题项目
	public void update(ShitiOption shitiOption) {
		this.getHibernateTemplate().update(shitiOption);
	}
	//删除试题项目
	public void delete(ShitiOption shitiOption) {
		this.getHibernateTemplate().delete(shitiOption);
	}
}

⌨️ 快捷键说明

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