?? shitioptiondaoimpl.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.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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -