?? wornginfdao.java
字號:
package xing.five.beans;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
import xing.five.util.Page;
/**
* Data access object (DAO) for domain model class WorngInf.
* @see com.hibernate.org.WorngInf
* @author MyEclipse - Hibernate Tools
*/
public class WorngInfDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(WorngInfDAO.class);
//property constants
public static final String PEL_ID = "pelId";
public static final String STATE = "state";
public static final String WORNG_NAME = "worngName";
public static final String WORD = "word";
public static final String PROJECT = "project";
public static final String KIND = "kind";
public static final String EMERGENCY = "emergency";
public static final String IMPORT_ = "import_";
public void save(WorngInf transientInstance) {
log.debug("saving WorngInf instance");
Session s=getSession();
try {
Transaction tr=s.beginTransaction();
getSession().save(transientInstance);
tr.commit();
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public List findByPage(final Page p){
List vehicleList = null;
try {
String hql = "from WorngInf as model where model.state=null order by b_date ";
Query q = getSession().createQuery(hql);
q.setFirstResult(p.getBeginIndex());
q.setMaxResults(p.getPageSize());
vehicleList = q.list();
} catch (RuntimeException he) {
throw he;
}
return vehicleList;
}
public int getRows() throws HibernateException {
int totalRows = 0;
try {
String hql = "from WorngInf as model where model.state=null order by b_date";
Session s=getSession();
Query q = s.createQuery(hql);
totalRows = q.list().size();
} catch (HibernateException he) {
throw he;
}
return totalRows;
}
public void update(WorngInf transientInstance) {
log.debug("saving WorngInf instance");
Session s=getSession();
try {
Transaction tr=s.beginTransaction();
// transientInstance.setState("已確認");
getSession().update(transientInstance);
log.debug("update successful");
tr.commit();
} catch (RuntimeException re) {
log.error("update failed", re);
throw re;
}
}
public void delete(WorngInf persistentInstance) {
log.debug("deleting WorngInf instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public WorngInf findById( java.lang.Integer id) {
log.debug("getting WorngInf instance with id: " + id);
try {
WorngInf instance = (WorngInf) getSession()
.get("xing.five.beans.WorngInf", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(WorngInf instance) {
log.debug("finding WorngInf instance by example");
try {
List results = getSession()
.createCriteria("com.hibernate.org.WorngInf")
.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;
}
}
public List findAll() {
log.debug("finding WorngInf instance with property: " );
try {
String queryString = "from WorngInf as model where model.state=null order by b_date" ;
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List find(String state)
{
Session session=HibernateSessionFactory.getSession();
String hql="from xing.five.beans.WorngInf as a where a.state=? ";
Query q=session.createQuery(hql);
q.setParameter(0, state);
List l=q.list();
return l;
}
public List findConf(String state) {
log.debug("finding WorngInf instance with property: " );
try {
String queryString = "from WorngInf as model where model.state=? order by b_date" ;
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, state);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding WorngInf instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from WorngInf as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByPelId(Object pelId) {
return findByProperty(PEL_ID, pelId);
}
public List findByState(Object state) {
return findByProperty(STATE, state);
}
public List findByWorngName(Object worngName) {
return findByProperty(WORNG_NAME, worngName);
}
public List findByWord(Object word) {
return findByProperty(WORD, word);
}
public List findByProject(Object project) {
return findByProperty(PROJECT, project);
}
public List findByKind(Object kind) {
return findByProperty(KIND, kind);
}
public List findByEmergency(Object emergency) {
return findByProperty(EMERGENCY, emergency);
}
public List findByImport_(Object import_) {
return findByProperty(IMPORT_, import_);
}
public WorngInf merge(WorngInf detachedInstance) {
log.debug("merging WorngInf instance");
try {
WorngInf result = (WorngInf) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(WorngInf instance) {
log.debug("attaching dirty WorngInf instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(WorngInf instance) {
log.debug("attaching clean WorngInf instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -