?? auditorrole1dao.java
字號:
package gdpe.hibernate.auro;
import java.util.List;
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.Transaction;
import org.hibernate.criterion.Example;
import gdpe.hibernate.department.*;
/**
* Data access object (DAO) for domain model class AuditorRole1.
* @see gdpe.hibernate.auro.AuditorRole1
* @author MyEclipse - Hibernate Tools
*/
public class AuditorRole1DAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(AuditorRole1DAO.class);
//property constants
public void save(AuditorRole1 transientInstance) {
log.debug("saving Auditor1 instance");
Transaction tx = null;
Session session = getSession();
try {
tx = session.beginTransaction();
session.save(transientInstance);
tx.commit();
// endTransaction(true);
System.out.println("------------>增加成功");
log.debug("增加成功");
} catch (RuntimeException re) {
tx.rollback();
log.error("save failed", re);
throw re;
} finally {
close(session);
}
}
public void delete(AuditorRole1 persistentInstance) {
log.debug("deleting AuditorRole1 instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public AuditorRole1 findById( gdpe.hibernate.auro.AuditorRole1Id id) {
log.debug("getting AuditorRole1 instance with id: " + id);
try {
AuditorRole1 instance = (AuditorRole1) getSession()
.get("gdpe.hibernate.auro.AuditorRole1", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(AuditorRole1 instance) {
log.debug("finding AuditorRole1 instance by example");
try {
List results = getSession()
.createCriteria("gdpe.hibernate.auro.AuditorRole1")
.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 findByProperty(String propertyName, Object value) {
log.debug("finding AuditorRole1 instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from AuditorRole1 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 AuditorRole1 merge(AuditorRole1 detachedInstance) {
log.debug("merging AuditorRole1 instance");
try {
AuditorRole1 result = (AuditorRole1) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(AuditorRole1 instance) {
log.debug("attaching dirty AuditorRole1 instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(AuditorRole1 instance) {
log.debug("attaching clean AuditorRole1 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 + -