📄 shititypedaoimpl.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -