📄 csubjectdao.java
字号:
package cn.hope.mana.pojo.dao;
import java.util.List;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import org.apache.log4j.Logger;
import cn.hope.mana.pojo.CSubject;
import cn.hope.mana.pojo.base.BaseCSubjectDAO;
public class CSubjectDAO extends BaseCSubjectDAO {
Logger log = Logger.getLogger(CSubjectDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public CSubjectDAO () {}
/*----------liul-------------------------------------------------------------------*/
public List U05searchCSubject() throws HibernateException {
List list = null;
String sqlStr = "select cSubject from CSubject cSubject where cSubject.flag='0'";
try {
initialize();
list = this.getSession().find(sqlStr);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return list;
}
public CSubject U05searchCSubject(Integer SSid) throws HibernateException {
CSubject cSubject=new CSubject();
List list = null;
String sqlStr = "select cSubject from CSubject cSubject where cSubject.flag='0' and cSubject.SSid='"+SSid+"'";
try {
initialize();
list = this.getSession().find(sqlStr);
if(list.size()>0){
cSubject=(CSubject)list.get(0);
}
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return cSubject;
}
/********************************lijia********************/
/**
* 查询数据方法
*
* @param
* @return list
* @throws HibernateException
*/
public List search() throws HibernateException {
String sql = "select cSubject from CSubject cSubject where cSubject.flag='0'";
try {
initialize();
return this.getSession().find(sql);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 键查询数据方法
*
* @param sSId
* @return CSubject
* @throws HibernateException
*/
public CSubject search(Integer sSId) throws HibernateException {
try {
initialize();
return this.load(sSId);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 值查询数据方法
*
* @param dName
* @return count
* @throws HibernateException
*/
public int search(String sSbname) throws HibernateException {
String sqlCnt = "select count(cSubject.SSid) from CSubject cSubject where cSubject.flag='0' and cSubject.SSbname='"
+sSbname+"'";
try {
initialize();
Query queryCnt = this.getSession().createQuery(sqlCnt);
return ((Integer)queryCnt.uniqueResult()).intValue();
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 添加数据方法
*
* @param cSubject
* @return
* @throws HibernateException
*/
public void insert(CSubject cSubject) throws HibernateException {
try{
initialize();
this.save(cSubject);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 删除数据方法
*
* @param cSubject
* @return
* @throws HibernateException
*/
public void delete(CSubject cSubject) throws HibernateException {
try{
initialize();
this.update(cSubject);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 修改数据方法
*
* @param cSubject
* @return
* @throws HibernateException
*/
public void update(CSubject cSubject) throws HibernateException {
try{
initialize();
super.update(cSubject);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 科目查询作业数据方法
*
* @param sSId
* @return List
* @throws HibernateException
*/
public List searchHomework(Integer sSid) throws HibernateException {
String sql = "select tHomework from THomework tHomework where tHomework.flag='0' and tHomework.CSubject.SSid="
+sSid;
try {
initialize();
return this.getSession().find(sql);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 科目查询教学表数据方法
*
* @param sSId
* @return List
* @throws HibernateException
*/
public List searchTeach(Integer sSid) throws HibernateException {
String sql = "select teach from Teach teach where teach.flag='0' and teach.CSubject.SSid="
+sSid;
try {
initialize();
return this.getSession().find(sql);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 科目查询考试表数据方法
*
* @param sSId
* @return List
* @throws HibernateException
*/
public List searchTInfo(Integer sSid) throws HibernateException {
String sql = "select tTestInfo from TTestInfo tTestInfo where tTestInfo.flag='0' and tTestInfo.CSubject.SSid="
+sSid;
try {
initialize();
return this.getSession().find(sql);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 科目查询试题表数据方法
*
* @param sSId
* @return List
* @throws HibernateException
*/
public List searchQuestion(Integer sSid) throws HibernateException {
String sql = "select tQuestion from TQuestion tQuestion where tQuestion.flag='0' and tQuestion.CSubject.SSid="
+sSid;
try {
initialize();
return this.getSession().find(sql);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -