View Javadoc

1   /*
2    * Created on Sep 14, 2004
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package ch.ledcom.hephaistos;
8   
9   import net.sf.hibernate.Criteria;
10  import net.sf.hibernate.HibernateException;
11  import net.sf.hibernate.Session;
12  import net.sf.hibernate.expression.Expression;
13  
14  import org.apache.log4j.Logger;
15  import org.apache.struts.action.ActionForm;
16  
17  import ch.ledcom.hephaistos.abstractActions.HibernateDeleteAction;
18  import ch.ledcom.hephaistos.dao.ProductClass;
19  
20  /***
21   * @author gehel
22   *
23   * @struts.action
24   *  path="/ProductClassDelete"
25   *  validate="false"
26   * @struts.action-forward
27   *  name="success"
28   *  path="/ProductClassList.do"  
29   * @struts.action-forward
30   *  name="failure"
31   *  path="/ProductClassList.do"
32   */
33  public class ProductClassDeleteAction extends HibernateDeleteAction {
34  
35    private static final Logger logger = Logger
36    .getLogger(ProductClassDeleteAction.class);
37  
38    /* (non-Javadoc)
39     * @see ch.ledcom.afs.web.HibernateGetAction#doGet(org.apache.struts.action.ActionForm, net.sf.hibernate.Session)
40     */
41    protected ActionForm doDelete(Long id, Session session)
42        throws HibernateException {
43      ProductClassForm form = new ProductClassForm();
44      Criteria criteria = session.createCriteria(ProductClass.class);
45      criteria.add(Expression.eq("id", id));
46      
47      ProductClass productClass = (ProductClass) criteria.uniqueResult();
48      
49      logger.info("Deleting productClass " + productClass.getNo());
50      
51      session.delete(productClass);
52          
53      return form;
54    }
55  
56  }