Ejemplo n.º 1
0
 // User defined finders/Buscadores definidos por el usuario
 public static FilterBySubfamily findBy() throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager().createQuery("from FilterBySubfamily as o");
     try {
       return (FilterBySubfamily) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "FilterBySubfamily"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession().createQuery("from FilterBySubfamily as o");
     FilterBySubfamily r = (FilterBySubfamily) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "FilterBySubfamily"));
     }
     return r;
   }
 }
Ejemplo n.º 2
0
 // User defined finders/Buscadores definidos por el usuario
 public static Size findById(int id) throws javax.ejb.ObjectNotFoundException {
   if (XavaPreferences.getInstance().isJPAPersistence()) {
     javax.persistence.Query query =
         org.openxava.jpa.XPersistence.getManager()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     try {
       return (Size) query.getSingleResult();
     } catch (Exception ex) {
       // In this way in order to work with Java pre 5
       if (ex.getClass().getName().equals("javax.persistence.NoResultException")) {
         throw new javax.ejb.ObjectNotFoundException(
             XavaResources.getString("object_not_found", "Size"));
       } else {
         ex.printStackTrace();
         throw new RuntimeException(ex.getMessage());
       }
     }
   } else {
     org.hibernate.Query query =
         org.openxava.hibernate.XHibernate.getSession()
             .createQuery("from Size as o where o.id = :arg0");
     query.setParameter("arg0", new Integer(id));
     Size r = (Size) query.uniqueResult();
     if (r == null) {
       throw new javax.ejb.ObjectNotFoundException(
           XavaResources.getString("object_not_found", "Size"));
     }
     return r;
   }
 }
  /**
   * Method 'execute'
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward handle(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      // parse parameters
      // create the DAO class
      TelesalesCallSourceDao dao = TelesalesCallSourceDaoFactory.create();

      // execute the finder
      TelesalesCallSource dto[] = dao.findAll();

      // store the results
      request.setAttribute("result", dto);

      return mapping.findForward("success");
    } catch (Exception e) {
      ActionErrors _errors = new ActionErrors();
      _errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage()));
      saveErrors(request, _errors);
      return mapping.findForward("failure");
    }
  }