Changeset 5129


Ignore:
Timestamp:
Oct 13, 2009, 8:49:22 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1400: Store the item id together with annotation sets

More progress reporting when updating an existing BASE installation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Update.java

    r5127 r5129  
    11401140      if (schemaVersion < 76)
    11411141      {
    1142         if (progress != null) progress.display((int)(75*progress_factor), "--Updating schema version: " + schemaVersion + " -> 76...");
    1143         schemaVersion = updateToSchemaVersion76(session);
     1142        if (progress != null) progress.display((int)(75*progress_factor),
     1143            "--Updating schema version: " + schemaVersion + " -> 76... (this may take a long time)");
     1144        schemaVersion = updateToSchemaVersion76(session, progress);
    11441145      }
    11451146
     
    25412542    @return The new schema version (=76)
    25422543  */
    2543   private static int updateToSchemaVersion76(org.hibernate.Session session)
     2544  private static int updateToSchemaVersion76(org.hibernate.Session session,
     2545    ProgressReporter progress)
    25442546    throws BaseException
    25452547  {
     
    25522554      ss = HibernateUtil.newStatelessSession(session);
    25532555     
     2556      // Count the number of annotation sets
     2557      org.hibernate.Query query = HibernateUtil.createQuery(ss,
     2558          "SELECT COUNT(*) FROM AnnotationSetData a " +
     2559          "WHERE a.itemId IS NULL");
     2560      long total = HibernateUtil.loadData(Long.class, query);
     2561      if (progress != null)
     2562      {
     2563        progress.append("\n\t--Updating " + total + " annotations");
     2564      }
     2565     
    25542566      // Load all annotation sets with a null id
    2555       org.hibernate.Query query = HibernateUtil.createQuery(ss,
     2567      query = HibernateUtil.createQuery(ss,
    25562568        "SELECT a FROM AnnotationSetData a WHERE a.itemId IS NULL");
    25572569      Iterator<AnnotationSetData> annotationSets =
    25582570        HibernateUtil.loadIterator(AnnotationSetData.class, query, null);
    25592571      Map<Item, org.hibernate.Query> itemQueries = new HashMap<Item, org.hibernate.Query>();
     2572      int numDone = 0;
    25602573      while (annotationSets.hasNext())
    25612574      {
     
    25742587        a.setItemId(HibernateUtil.loadData(Integer.class, findItem));
    25752588        ss.update(a);
     2589        numDone++;
     2590        if (progress != null && numDone % 100 == 0)
     2591        {
     2592          progress.append("\r\t--" + numDone + " of " + total + " annotations done");
     2593        }
    25762594      }
    25772595 
Note: See TracChangeset for help on using the changeset viewer.