📄 sblogtypedao.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.SBlog;
import cn.hope.mana.pojo.SBlogtype;
import cn.hope.mana.pojo.base.BaseSBlogtypeDAO;
public class SBlogtypeDAO extends BaseSBlogtypeDAO {
Logger log = Logger.getLogger(SBlogtypeDAO.class.getName());
/**
* Default constructor. Can be used in place of getInstance()
*/
public SBlogtypeDAO () {}
/**
* 查询数据方法
*
* @param
* @return list
* @throws HibernateException
*/
public List search() throws HibernateException {
String sql = "select sBlogtype from SBlogtype sBlogtype where sBlogtype.flag='0'";
try {
initialize();
return this.getSession().find(sql);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 键查询数据方法
*
* @param bId
* @return SBlogtype
* @throws HibernateException
*/
public SBlogtype search(Integer bId) throws HibernateException {
try {
initialize();
return this.load(bId);
} catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 值查询数据方法
*
* @param dName
* @return count
* @throws HibernateException
*/
public int search(String tTitle) throws HibernateException {
String sqlCnt = "select count(sBlogtype.stId) from SBlogtype sBlogtype where sBlogtype.flag='0' and sBlogtype.stTitle='"
+tTitle+"'";
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 sBlogtype
* @return
* @throws HibernateException
*/
public void insert(SBlogtype sBlogtype) throws HibernateException {
try{
initialize();
this.save(sBlogtype);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 删除数据方法
*
* @param sBlogtype
* @return
* @throws HibernateException
*/
public void delete(SBlogtype sBlogtype) throws HibernateException {
try{
initialize();
this.update(sBlogtype);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 修改数据方法
*
* @param sBlogtype
* @return
* @throws HibernateException
*/
public void update(SBlogtype sBlogtype) throws HibernateException {
try{
initialize();
super.update(sBlogtype);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* 修改blog数据方法
*
* @param sBlog
* @return
* @throws HibernateException
*/
public void update(SBlog sBlog) throws HibernateException {
try{
initialize();
new SBlogDAO().update(sBlog);
}catch (HibernateException e) {
log.error(e);
e.printStackTrace();
throw new HibernateException(e);
} finally {
closeCurrentThreadSessions();
}
}
/**
* blog分类查询blog数据方法
*
* @param sBlogtype
* @return List
* @throws HibernateException
*/
public List searchBlog(Integer bId) throws HibernateException {
String sql = "select sBlog from SBlog sBlog where sBlog.flag='0' and sBlog.SBlogtype.stId="
+bId;
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 + -