?? rolemgmtdaobyhibernate.java
字號:
package com.tarena.oss.rights.dao;
import java.sql.SQLException;
import java.util.Collection;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.tarena.oss.rights.pojo.Rights;
import com.tarena.oss.rights.pojo.Role;
public class RoleMgmtDAOByHibernate extends HibernateDaoSupport implements
RoleMgmtDAO {
public void deleteRole(Role r) {
this.getHibernateTemplate().delete(r);
}
public void insertRole(Role r) {
this.getHibernateTemplate().save(r);
}
public boolean isUsed(Integer id) {
// TODO Auto-generated method stub
return false;
}
public Collection<Role> queryAll() {
return this.getHibernateTemplate().find("from Role");
}
public Collection<Role> queryAll(int currentPage, int rowCnt) {
final int start =(currentPage-1)*rowCnt;
final int rows=rowCnt;
return this.getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
org.hibernate.Query query =session.createQuery("from Rights");
query.setFirstResult(start);
query.setMaxResults(rows);
return query.list();
}
});
}
public Role queryRoleById(Integer id) {
return (Role) this.getHibernateTemplate().get(Role.class, id);
}
public int queryRowCounts() {
Long l=(Long) this.getHibernateTemplate().find("select count(*)from Role").get(0);
return l.intValue();
}
public int queryRowCounts(String condition) {
// TODO Auto-generated method stub
return 0;
}
public void updateRole(Role r) {
this.getHibernateTemplate().saveOrUpdate(r);
}
public Collection<Role> queryAll(String condition) {
return this.getHibernateTemplate().find("from Role r where 1=1" +condition);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -