📄 adminrolesdao.java
字号:
package netctoss.dao;
import java.util.List;
import netctoss.entities.Adminroles;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
public class AdminrolesDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(AdminrolesDAO.class);
// property constants
public static final String ADMINID = "adminid";
public static final String ROLEID = "roleid";
public void save(Adminroles transientInstance) {
log.debug("saving Adminroles instance");
try {
Transaction t=this.getSession().beginTransaction();
getSession().save(transientInstance);
t.commit();
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Adminroles persistentInstance) {
log.debug("deleting Adminroles instance");
try {
Transaction t=this.getSession().beginTransaction();
getSession().delete(persistentInstance);
t.commit();
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public void deleteByRoleID(Integer roleid) {
log.debug("deleting Adminroles instance");
try {
//System.out.println("删除的角色:"+roleid);
String hql="";
hql+="from netctoss.entities.Adminroles ar ";
hql+="where ar.roleid="+roleid;
List lst=this.getSession().createQuery(hql).list();
//System.out.println("删除的角色个数:"+lst.size());
for(Object obj:lst){
delete((Adminroles)obj);
}
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public void deleteByNullAdminID() {
log.debug("deleting Adminroles instance");
try {
//System.out.println("删除的角色:"+roleid);
String hql="";
hql+="from netctoss.entities.Adminroles ar ";
hql+="where ar.adminid is null";
List lst=this.getSession().createQuery(hql).list();
System.out.println("删除的角色个数:"+lst.size());
for(Object obj:lst){
delete((Adminroles)obj);
}
log.debug("delete successful");
} catch (RuntimeException re) {
throw re;
}
}
public List findByAdminRoleID(Integer adminid,Integer roleid){
String hql="from netctoss.entities.Adminroles adminroles ";
hql+="where adminroles.roleid="+roleid+" ";
hql+="and ";
hql+="adminroles.adminid="+adminid;
Query query=this.getSession().createQuery(hql);
return query.list();
}
public Adminroles findById(java.lang.Integer id) {
log.debug("getting Adminroles instance with id: " + id);
try {
Adminroles instance = (Adminroles) getSession().get(
"netctoss.entities.Adminroles", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Adminroles instance) {
log.debug("finding Adminroles instance by example");
try {
List results = getSession().createCriteria(
"netctoss.entities.Adminroles").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 Adminroles instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Adminroles 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 findByAdminid(Object adminid) {
return findByProperty(ADMINID, adminid);
}
public List findByRoleid(Object roleid) {
return findByProperty(ROLEID, roleid);
}
public List findAll() {
log.debug("finding all Adminroles instances");
try {
String queryString = "from Adminroles";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Adminroles merge(Adminroles detachedInstance) {
log.debug("merging Adminroles instance");
try {
Adminroles result = (Adminroles) getSession().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Adminroles instance) {
log.debug("attaching dirty Adminroles instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Adminroles instance) {
log.debug("attaching clean Adminroles 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 + -