actiondaohibernate.java

来自「《JSP网站开发典型模块与实例精讲》一书光盘源码」· Java 代码 · 共 49 行

JAVA
49
字号
package org.appfuse.dao.hibernate;

import java.util.List;

import org.springframework.orm.ObjectRetrievalFailureException;

import org.appfuse.dao.*;
import org.appfuse.model.Action;
import org.appfuse.util.exception.AppDAOException;
import org.appfuse.model.RoleAuth;

/**
 * @author user
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ActionDAOHibernate
    extends BaseDAOHibernate
    implements ActionDAO {
    public Action getAction(int actionid) throws AppDAOException {
        Action action = (Action) getHibernateTemplate().get(Action.class,
            new Integer(actionid));

        if (action == null) {
            throw new ObjectRetrievalFailureException(Action.class,
                new Integer(actionid));
        }

        return action;
    }

    public List getActions(Action action) throws AppDAOException {
        return getHibernateTemplate().find(
            "from Action");
    }

    public void saveAction(final Action action) throws AppDAOException {
        getHibernateTemplate().saveOrUpdate(action);
        getHibernateTemplate().flush();
    }

    public void removeAction(int actionid) throws AppDAOException {
        Action action = getAction(actionid);
        getHibernateTemplate().delete(action);
    }

}

⌨️ 快捷键说明

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