📄 u01mntypebo.java
字号:
package cn.hope.mana.bo;
import java.util.Iterator;
import java.util.List;
import net.sf.hibernate.HibernateException;
import org.apache.log4j.Logger;
import cn.hope.mana.pojo.MNounce;
import cn.hope.mana.pojo.MNtype;
import cn.hope.mana.pojo.dao.MNounceDAO;
import cn.hope.mana.pojo.dao.MNtypeDAO;
public class U01MNtypeBO {
Logger log = Logger.getLogger(U01MNtypeBO.class.getName());
private MNtypeDAO ntypeDAO = new MNtypeDAO();
public List searchAll() throws HibernateException{
try{
return ntypeDAO.searchAll();
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
}
/**
* 查询数据方法
*
* @param
* @return MHtype
* @throws HibernateException
*/
public MNtype find(Integer typeId) throws HibernateException {
try {
return ntypeDAO.load(typeId);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
}
/**
* 修改数据方法
*
* @param MHtype
* @return void
* @throws HibernateException
*/
public boolean update(MNtype mNtype) throws HibernateException {
mNtype.setNType(mNtype.getNType().trim());
int count = 0;
try {
count = ntypeDAO.searchByName(mNtype.getNType());
if (count == 0) {
ntypeDAO.update(mNtype);
return true;
}
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
return false;
}
/**
* 删除数据方法
*
* @param Integer
* @return void
* @throws HibernateException
*/
public void delete(Integer typeId) throws HibernateException {
MNounceDAO mnDAO = new MNounceDAO();
MNtype mNtype = new MNtype();
List list = null;
try {
mNtype = ntypeDAO.load(typeId);
/**先删除公告**/
list = mnDAO.search(mNtype);
Iterator it = list.iterator();
while (it.hasNext()){
MNounce mn = (MNounce) it.next();
mn.setFlag("1");
mnDAO.delete(mn);
}
/*********/
mNtype.setFlag("1");
ntypeDAO.update(mNtype);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -