📄 cdeptdao.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.CDept;
import cn.hope.mana.pojo.base.BaseCDeptDAO;
public class CDeptDAO extends BaseCDeptDAO {
Logger log = Logger.getLogger(CDeptDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public CDeptDAO () {}
/**
* 查询数据方法
*
* @param
* @return list
* @throws HibernateException
*/
public List search() throws HibernateException {
String sql = "select cDept from CDept cDept where cDept.flag='0'";
try {
initialize();
return this.getSession().find(sql);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 键查询数据方法
*
* @param dId
* @return CDept
* @throws HibernateException
*/
public CDept search(Integer dId) throws HibernateException {
try {
initialize();
return this.load(dId);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 值查询数据方法
*
* @param dName
* @return count
* @throws HibernateException
*/
public int search(String dName) throws HibernateException {
String sqlCnt = "select count(cDept.DId) from CDept cDept where cDept.flag='0' and cDept.DName='"
+dName+"'";
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 cDept
* @return
* @throws HibernateException
*/
public void insert(CDept cDept) throws HibernateException {
try{
initialize();
this.save(cDept);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 删除数据方法
*
* @param cDept
* @return
* @throws HibernateException
*/
public void delete(CDept cDept) throws HibernateException {
try{
initialize();
this.update(cDept);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 修改数据方法
*
* @param cDept
* @return
* @throws HibernateException
*/
public void update(CDept cDept) throws HibernateException {
try{
initialize();
super.update(cDept);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 部门查询班级数据方法
*
* @param cDept
* @return List
* @throws HibernateException
*/
public List searchClass(Integer dId) throws HibernateException {
String sql = "select sClass from SClass sClass where sClass.flag='0' and sClass.CDept.DId="
+dId;
try {
initialize();
return this.getSession().find(sql);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 部门查询教师数据方法
*
* @param cDept
* @return List
* @throws HibernateException
*/
public List searchTInfo(Integer dId) throws HibernateException {
String sql = "select tInfo from TInfo tInfo where tInfo.flag='0' and tInfo.CDept.DId="
+dId;
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 + -