⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staffroledaohibernate.java

📁 《JSP网站开发典型模块与实例精讲》一书光盘源码
💻 JAVA
字号:
/*
 * Created on 2006-2-3
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.appfuse.dao.hibernate;

import java.util.List;

import org.springframework.orm.ObjectRetrievalFailureException;

import org.appfuse.dao.StaffRoleDAO;
import org.appfuse.model.*;

/**
 * @author user
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class StaffRoleDAOHibernate
    extends BaseDAOHibernate
    implements StaffRoleDAO {

    private List getStaffRole(StaffRole staffRole) {
//        return (List) getHibernateTemplate().find(
//            "from StaffRole a where a.staffno = " +
//            staffRole.getStaffno() +
//            " and a.roleid = " + staffRole.getRoleid());
        return getHibernateTemplate().find(
            "from StaffRole a where a.staffno = ? and a.roleid = ?",
            new Object[]{new Integer(staffRole.getStaffno()), new Integer(staffRole.getRoleid())});

    }

    public void saveStaffRole(final StaffRole staffRole) {
        getHibernateTemplate().saveOrUpdate(staffRole);
        getHibernateTemplate().flush();
    }

    public void removeStaffRole(StaffRole staffRole) {
        List list = getStaffRole(staffRole);
        for(int i = 0; i < list.size(); i++){
            staffRole = (StaffRole)list.get(i);
            getHibernateTemplate().delete(staffRole);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -