Changeset 5403


Ignore:
Timestamp:
Sep 6, 2010, 12:44:50 PM (12 years ago)
Author:
Martin Svensson
Message:

Fixes #1507. Burp trying to empty trashcan.

Location:
trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r5390 r5403  
    38603860    </description>
    38613861  </query>
     3862 
     3863  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
     3864    <sql>
     3865      UPDATE DiskUsageData du
     3866        SET du.group = null
     3867        WHERE du.group = :group
     3868    </sql>
     3869    <description>
     3870      An HQL update-query that sets group to null on all
     3871      diskusage that are associated with a given group.
     3872    </description>
     3873  </query>
    38623874
    38633875</predefined-queries>
  • trunk/src/core/net/sf/basedb/core/Group.java

    r5384 r5403  
    2424package net.sf.basedb.core;
    2525
     26import net.sf.basedb.core.Transactional.Action;
    2627import net.sf.basedb.core.data.GroupData;
    2728import net.sf.basedb.core.hibernate.TypeWrapper;
     
    248249    -------------------------------------------
    249250  */
     251  /**
     252    Set group to null in disk usage
     253    where this group is referenced.
     254  */
     255  @Override
     256  void onBeforeCommit(Action action)
     257  {
     258    super.onBeforeCommit(action);
     259   
     260    if (action == Transactional.Action.DELETE)
     261    {
     262      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(
     263          getDbControl().getHibernateSession(), "SET_GROUP_TO_NULL_ON_DISK_USAGE");
     264      /*
     265        UPDATE [DiskUsage]
     266        SET [group] = null
     267        WHERE [group] = :group
     268      */
     269      query.setInteger("group", getId());
     270      HibernateUtil.executeUpdate(query);     
     271    }
     272  }
    250273  /**
    251274    Checks if:
Note: See TracChangeset for help on using the changeset viewer.