📄 mhelpdao.java
字号:
package cn.hope.mana.pojo.dao;
import java.util.List;
import org.apache.log4j.Logger;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import cn.hope.mana.pojo.MHelp;
import cn.hope.mana.pojo.MHtype;
import cn.hope.mana.pojo.base.BaseMHelpDAO;
public class MHelpDAO extends BaseMHelpDAO {
Logger log = Logger.getLogger(MHelpDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public MHelpDAO () {}
/**
* 查询数据方法
*
* @param MHtype
* @return U01MHelpVO
* @throws HibernateException
*/
public List search(MHtype mHtype) throws HibernateException {
List list = null;
String sqlStr = "select mHelp from MHelp mHelp where mHelp.flag='0' and mHelp.MHtype.htId='"
+mHtype.getHtId()+"'";
try {
initialize();
list = this.getSession().find(sqlStr);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
return list;
}
/**
* 查询数据方法
*
* @param Integer
* @return MHelp
* @throws HibernateException
*/
public MHelp searchByKey(Integer key) throws HibernateException {
try {
initialize();
return this.get(key);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 删除数据方法
*
* @param Integer
* @return boolean
* @throws HibernateException
*/
public void delete(MHelp mHelp) throws HibernateException {
try {
initialize();
this.update(mHelp);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 添加数据方法
*
* @param MHelp
* @return
* @throws HibernateException
*/
public void insert(MHelp mHelp) throws HibernateException {
try {
initialize();
this.save(mHelp);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 查询数据方法
*
* @param Integer
* @return MHelp
* @throws HibernateException
*/
public MHelp find(Integer hId) throws HibernateException{
try {
initialize();
return this.load(hId);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 修改数据方法
*
* @param MHelp
* @return
* @throws HibernateException
*/
public void update(MHelp mHelp) throws HibernateException{
try {
initialize();
super.update(mHelp);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 查询数据方法
*
* @param hTitle
* @return count
* @throws HibernateException
*/
public int searchByName(String hTitle) throws HibernateException{
String sqlCnt = "select count(mHelp.HId) from MHelp mHelp where mHelp.flag='0' and mHelp.HTitle='"
+hTitle+"'";
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 hTitle
* @param hid
* @return count
* @throws HibernateException
*/
public int search(String hTitle,int hid) throws HibernateException{
String sqlCnt = "select count(mHelp.HId) from MHelp mHelp where mHelp.flag='0' and mHelp.HTitle='"
+hTitle+"' and mHelp.HId<>" + hid;
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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -