?? shititypedaoimpl.java
字號(hào):
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;
}
//查詢?cè)囶}種類
public ShitiType query(String name) {
ShitiType shitiType = null;
//如果查詢結(jié)果為空
if (this.getHibernateTemplate().find(hql, name) == null ) {
shitiType = null;
} else {
//不為空時(shí),取第一筆
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);
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -