Changeset 424 for trunk/grails-app
- Timestamp:
- Mar 2, 2010, 5:26:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/AssetCsvService.groovy
r421 r424 1 import grails.util.GrailsUtil 1 2 import au.com.bytecode.opencsv.CSVWriter 2 3 import au.com.bytecode.opencsv.CSVReader … … 12 13 13 14 def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() 15 16 def sessionFactory 17 def propertyInstanceMap = org.codehaus.groovy.grails.plugins.DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP 14 18 15 19 /** … … 259 263 260 264 } // while( nextColumn() ) 265 266 if(lineNumber % 100 == 0) 267 cleanUpGorm() 261 268 262 269 nextLine() … … 448 455 } 449 456 457 /** 458 * This cleans up the hibernate session and a grails map. 459 * For more info see: http://naleid.com/blog/2009/10/01/batch-import-performance-with-grails-and-mysql/ 460 * The hibernate session flush is normal for hibernate. 461 * The map is apparently used by grails for domain object validation errors. 462 * A starting point for clean up is every 100 objects. 463 */ 464 def cleanUpGorm() { 465 def session = sessionFactory.currentSession 466 session.flush() 467 session.clear() 468 propertyInstanceMap.get().clear() 469 } 470 450 471 } // end class
Note: See TracChangeset
for help on using the changeset viewer.