Changeset 5129
- Timestamp:
- Oct 13, 2009, 8:49:22 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Update.java
r5127 r5129 1140 1140 if (schemaVersion < 76) 1141 1141 { 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); 1144 1145 } 1145 1146 … … 2541 2542 @return The new schema version (=76) 2542 2543 */ 2543 private static int updateToSchemaVersion76(org.hibernate.Session session) 2544 private static int updateToSchemaVersion76(org.hibernate.Session session, 2545 ProgressReporter progress) 2544 2546 throws BaseException 2545 2547 { … … 2552 2554 ss = HibernateUtil.newStatelessSession(session); 2553 2555 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 2554 2566 // Load all annotation sets with a null id 2555 org.hibernate.Queryquery = HibernateUtil.createQuery(ss,2567 query = HibernateUtil.createQuery(ss, 2556 2568 "SELECT a FROM AnnotationSetData a WHERE a.itemId IS NULL"); 2557 2569 Iterator<AnnotationSetData> annotationSets = 2558 2570 HibernateUtil.loadIterator(AnnotationSetData.class, query, null); 2559 2571 Map<Item, org.hibernate.Query> itemQueries = new HashMap<Item, org.hibernate.Query>(); 2572 int numDone = 0; 2560 2573 while (annotationSets.hasNext()) 2561 2574 { … … 2574 2587 a.setItemId(HibernateUtil.loadData(Integer.class, findItem)); 2575 2588 ss.update(a); 2589 numDone++; 2590 if (progress != null && numDone % 100 == 0) 2591 { 2592 progress.append("\r\t--" + numDone + " of " + total + " annotations done"); 2593 } 2576 2594 } 2577 2595
Note: See TracChangeset
for help on using the changeset viewer.