KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cash > action > HibernateAction


1 package cash.action;
2
3 import org.apache.log4j.Logger;
4
5 import com.opensymphony.xwork.ActionContext;
6 import com.opensymphony.xwork.ActionSupport;
7
8 /**
9  * Superclass for Hibernate-aware actions.
10  *
11  * @author Joel Hockey
12  * @version $Id: HibernateAction.java,v 1.9 2004/12/14 22:45:55 plightbo Exp $
13  */

14 public abstract class HibernateAction extends ActionSupport {
15     /** xwork action return code */
16     public static final String JavaDoc DBERROR = "dberror";
17
18     private static final Logger LOG = Logger.getLogger(HibernateAction.class);
19
20     private boolean m_rollback = false;
21
22     /** roll back the current session */
23     protected void setRollbackOnly() { m_rollback = true; }
24
25     /** @return whether the current Hibernate Session should be rolled back */
26     public boolean getRollback() { return m_rollback; }
27
28     /**
29      * Sets an object into the web session
30      * @param key Key used to index object
31      * @param object The object to store
32      */

33     public void set(Object JavaDoc key, Object JavaDoc object) {
34         ActionContext.getContext().getSession().put(key, object);
35     }
36
37     /**
38      * Retrieve object from web session
39      * @param key Key used to index object
40      * @return object if it exists, or null
41      */

42     public Object JavaDoc get(Object JavaDoc key) {
43         return ActionContext.getContext().getSession().get(key);
44     }
45 }
46
47
48
Popular Tags