📄 catalogtabledao.java
字号:
package com.xfaccp.bookonline.hib.dao;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Example;
import com.xfaccp.bookonline.hib.dao.base.BaseHibernateDAO;
import com.xfaccp.bookonline.hib.dto.CatalogTable;
/**
* Data access object (DAO) for domain model class CatalogTable.
*
* @see com.xfaccp.bookonline.hib.dto.CatalogTable
* @author MyEclipse - Hibernate Tools
*/
public class CatalogTableDAO extends BaseHibernateDAO {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(CatalogTableDAO.class);
// property constants
public static final String CATALOGNAME = "catalogname";
public CatalogTable findById(java.lang.Integer id) {
log.debug("getting CatalogTable instance with id: " + id);
Session session = this.getSession();
try {
CatalogTable instance = (CatalogTable) session.get(
"com.xfaccp.bookonline.hib.dto.CatalogTable", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(CatalogTable instance) {
log.debug("finding CatalogTable instance by example");
Session session = this.getSession();
try {
List results = session.createCriteria(
"com.xfaccp.bookonline.hib.dto.CatalogTable").add(
Example.create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
} finally {
session.close();
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding CatalogTable instance with property: "
+ propertyName + ", value: " + value);
Session session = this.getSession();
try {
String queryString = "from CatalogTable as model where model."
+ propertyName + "= ?";
Query queryObject = session.createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
} finally {
session.close();
}
}
public List findByCatalogname(Object catalogname) {
return findByProperty(CATALOGNAME, catalogname);
}
public CatalogTable merge(CatalogTable detachedInstance) {
log.debug("merging CatalogTable instance");
Session session = this.getSession();
try {
CatalogTable result = (CatalogTable) session
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
} finally {
session.close();
}
}
public void attachDirty(CatalogTable instance) {
log.debug("attaching dirty CatalogTable instance");
Session session = this.getSession();
try {
session.saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
} finally {
session.close();
}
}
public void attachClean(CatalogTable instance) {
log.debug("attaching clean CatalogTable instance");
Session session = this.getSession();
try {
session.lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
} finally {
session.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -