package com.tansuo.dao;
import java.sql.SQLException;
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.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.tansuo.entity.Roletree;
/**
* Data access object (DAO) for domain model class Roletree.
*
* @see com.tansuo.entity.Roletree
* @author MyEclipse Persistence Tools
*/
public class RoletreeDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(RoletreeDAO.class);
// property constants
protected void initDao() {
// do nothing
}
@SuppressWarnings("unchecked")
public String[] findByRoleId(int id){
String hql = "from Roletree as rt where rt.role.roleId="+id;
List<Roletree> list = this.getHibernateTemplate().find(hql);
String[] role = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
role[i]=list.get(i).getTree().getTreeId()+"";
}
return role;
}
public void save(Roletree transientInstance) {
log.debug("saving Roletree instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void deleteByRole(int id){
final String hql = "delete from Roletree as rt where rt.role.roleId="+id;
this.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.createQuery(hql);
query.executeUpdate();
return null;
}});
}
public void delete(Roletree persistentInstance) {
log.debug("deleting Roletree instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Roletree findById(java.lang.Integer id) {
log.debug("getting Roletree instance with id: " + id);
try {
Roletree instance = (Roletree) getHibernateTemplate().get(
"com.tansuo.entity.Roletree", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Roletree instance) {
log.debug("finding Roletree instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
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 Roletree instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Roletree as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findAll() {
log.debug("finding all Roletree instances");
try {
String queryString = "from Roletree";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Roletree merge(Roletree detachedInstance) {
log.debug("merging Roletree instance");
try {
Roletree result = (Roletree) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Roletree instance) {
log.debug("attaching dirty Roletree instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Roletree instance) {
log.debug("attaching clean Roletree instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static RoletreeDAO getFromApplicationContext(ApplicationContext ctx) {
return (RoletreeDAO) ctx.getBean("RoletreeDAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
权限树,就是也权限控制
共133个文件
tld:23个
class:23个
java:22个
1星 需积分: 10 11 下载量 122 浏览量
2010-06-03
12:50:36
上传
评论
收藏 1.89MB RAR 举报
温馨提示
package com.tansuo.biz; import java.util.List; import com.tansuo.dao.RoleDAO; import com.tansuo.entity.Role; public class RoleBiz { private RoleDAO rdao; public void setRdao(RoleDAO rdao) { this.rdao = rdao; } public void save(Role role){ rdao.save(role); } public void delete(int id){ rdao.delete(rdao.findById(id)); } public Role findbyid(int id){ return rdao.findById(id); } public void update(Role role){ rdao.attachDirty(role); } public List findall(){ return rdao.findAll(); } }
资源推荐
资源详情
资源评论
收起资源包目录
权限树,就是也权限控制 (133个子文件)
UserinfoDAO.class 6KB
RoletreeDAO.class 6KB
TreeDAO.class 5KB
RoleDAO.class 5KB
UserinfoAction.class 4KB
TreeAction.class 4KB
RoleAction.class 3KB
UserinfoForm.class 2KB
RoleTreeBiz.class 2KB
TreeForm.class 2KB
Tree.class 2KB
RoleForm.class 2KB
RoletreeAction.class 2KB
Role.class 2KB
Userinfo.class 2KB
Roletree.class 2KB
UserinfoBiz.class 1KB
RoleBiz.class 1KB
TreeBiz.class 1KB
RoletreeForm.class 1KB
RoletreeDAO$1.class 1KB
MyRequestProcessor.class 975B
Tool.class 697B
.classpath 2KB
open.gif 910B
close.gif 909B
file.gif 810B
spacer.gif 43B
on.html 414B
right.html 386B
frame.html 274B
mysql-connector-java-5.0.3-bin.jar 482KB
struts.jar 428KB
standard.jar 343KB
commons-collections.jar 160KB
commons-beanutils.jar 100KB
commons-digester.jar 96KB
jakarta-oro.jar 62KB
commons-lang.jar 53KB
commons-validator.jar 40KB
commons-logging.jar 27KB
commons-fileupload.jar 19KB
jstl.jar 17KB
struts-legacy.jar 9KB
RoletreeDAO.java 5KB
UserinfoDAO.java 4KB
UserinfoAction.java 4KB
TreeDAO.java 4KB
RoleDAO.java 4KB
TreeAction.java 4KB
RoleAction.java 2KB
UserinfoForm.java 2KB
TreeForm.java 2KB
Tree.java 1KB
RoleForm.java 1KB
Role.java 1KB
RoletreeAction.java 1KB
Userinfo.java 1KB
RoletreeForm.java 1KB
Roletree.java 1KB
RoleTreeBiz.java 997B
UserinfoBiz.java 650B
MyRequestProcessor.java 633B
TreeBiz.java 555B
RoleBiz.java 546B
Tool.java 341B
index.jpg 148KB
top.jpg 36KB
loginBg.jpg 422B
treelist.jsp 5KB
treemanager.jsp 5KB
index.jsp 4KB
userinfolist.jsp 1KB
updateuserinfo.jsp 1KB
adduserinfo.jsp 1KB
rolelist.jsp 952B
login.jsp 930B
updatetree.jsp 869B
addtree.jsp 804B
updaterole.jsp 733B
addrole.jsp 604B
.struts-config.mex 12KB
MANIFEST.MF 39B
.myhibernatedata 495B
.mymetadata 285B
.mystrutsdata 257B
.project 2KB
log4j.properties 592B
log4j.properties 592B
ApplicationResources.properties 504B
ApplicationResources.properties 504B
ApplicationResources_zh_CN.properties 199B
ApplicationResources_zh_CN.properties 199B
ApplicationResources_en.properties 173B
ApplicationResources_en.properties 173B
.springBeans 320B
role.sql 3KB
struts-html.tld 65KB
struts-nested.tld 63KB
spring-form.tld 51KB
共 133 条
- 1
- 2
资源评论
- javawang20072012-12-05不能运行,而且是sturts1
keyuxuan1987
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功