Changeset 6532


Ignore:
Timestamp:
Sep 22, 2014, 8:24:33 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1845: Changing the conversion formula for a unit doesn't invalidate the snapshot cache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/core/net/sf/basedb/core/Unit.java

    r6127 r6532  
    2424import java.util.HashSet;
    2525import java.util.Iterator;
     26import java.util.List;
    2627import java.util.Set;
    2728import java.util.TreeSet;
    2829
    2930import net.sf.basedb.core.Transactional.Action;
     31import net.sf.basedb.core.data.AnnotationSetData;
    3032import net.sf.basedb.core.data.QuantityData;
    3133import net.sf.basedb.core.data.UnitData;
    3234import net.sf.basedb.core.data.UnitSymbolData;
     35import net.sf.basedb.core.snapshot.SnapshotManager;
    3336import net.sf.basedb.util.formatter.Formatter;
    3437import net.sf.basedb.util.formatter.PrefixSuffixFormatter;
     
    550553          HibernateUtil.executeUpdate(query);
    551554        }
     555       
     556        // We also need to invalidate the annotations in the snapshot cache
     557        org.hibernate.Query query = HibernateUtil.createQuery(getDbControl().getHibernateSession(),
     558          "SELECT a.annotationSet " +
     559          "FROM AnnotationData a " +
     560          "INNER JOIN a.annotationType at " +
     561          "WHERE (a.unit = :unit OR at.defaultUnit = :unit) AND a.unit <> at.defaultUnit");
     562        query.setEntity("unit", getData());
     563        List<AnnotationSetData> tmp = HibernateUtil.loadList(AnnotationSetData.class, query, getSessionControl());
     564        for (AnnotationSetData as : tmp)
     565        {
     566          SnapshotManager.removeSnapshot(as.getId());
     567        }
    552568      }
    553569    }
Note: See TracChangeset for help on using the changeset viewer.