Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-28842

HibernateException and other Exceptions differentiation at SiteStats

    XMLWordPrintable

    Details

    • Type: Task
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.0, 2.5.6, 2.6.3, 11.0
    • Fix Version/s: 2.5.6, 2.6.3
    • Component/s: Sitestats
    • Labels:
      None

      Description

      When processing events, activities and so on, if an Exception is lanched there is no way of knowing if it an HibernateException or another type of Exception.
      For example, an invocation to Criteria.uniqueResult() (see SiteStatsUpdateManagerImpl methods doUpdateXXXXXObjects) will retrieve a unique object or list of objects verifying the query conditions. The list can be accessing catching HibernateException. However, at SiteStatsUpdateManagerImpl this exception is caught together with all exceptions, as they are inside the same try-catch block. On the other part, it is possible for the list retrieved to be null (no result retrieved) and this will launch other exception. Thus, I propose to use the following block structure:

      Criteria c = session.createCriteria(SiteActivityImpl.class);
      c.add(Expression.eq("siteId", eUpdate.getSiteId()));
      c.add(Expression.eq("eventId", eUpdate.getEventId()));
      c.add(Expression.eq("date", eUpdate.getDate()));
      try

      { eExisting = (SiteActivity) c.uniqueResult(); }

      catch(HibernateException ex){
      List events = c.list();
      if ((events!=null) && (events.size()>0))

      { LOG.debug("More than 1 result when unique result expected.", ex); eExisting = (SiteActivity) c.list().get(0); }

      else

      { LOG.debug("No result found", ex); eExisting = null; }

      }catch(Exception ex2){
      LOG.debug("Probably ddbb error when loading data at java object", ex2);

      I attach the patch to apply this modification to all SiteStatsUpdateManagerImpl methods doUpdateXXXXXObjects methods for revision 54374.

      Hope this helps.

      David

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  nfernandes Nuno Fernandes (Inactive)
                  Reporter:
                  darolmar@abierta.upv.es David Roldán Martínez
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Git Source Code