shititypedaoimpl.java
来自「简单的在线考试系统。用户注册、登陆、设定视图类型、种类、试题项目、试题题目、组织」· Java 代码 · 共 45 行
JAVA
45 行
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.ShitiType;
import com.myExam.dao.ShitiTypeDAO;
public class ShitiTypeDAOImpl extends HibernateDaoSupport implements ShitiTypeDAO{
private SessionFactory sessionFactory;
private String hql = "from ShitiType u where u.name = ?";
private String hql1 = "from ShitiType u";
//查询多笔试题种类
public List queryList() {
List list = new ArrayList();
list = this.getHibernateTemplate().find(hql1);
return list;
}
//查询试题种类
public ShitiType query(String name) {
ShitiType shitiType = null;
//如果查询结果为空
if (this.getHibernateTemplate().find(hql, name) == null ) {
shitiType = null;
} else {
//不为空时,取第一笔
shitiType = (ShitiType)(this.getHibernateTemplate().find(hql, name).get(0));
}
return shitiType;
}
//新增试题种类
public void insert(ShitiType shitiType) {
this.getHibernateTemplate().save(shitiType);
}
//修改试题种类
public void update(ShitiType shitiType) {
this.getHibernateTemplate().update(shitiType);
}
//删除试题种类
public void delete(ShitiType shitiType) {
this.getHibernateTemplate().delete(shitiType);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?