Ignore:
Timestamp:
Mar 4, 2011, 12:30:52 PM (9 years ago)
Author:
s.h.sikkema@…
Message:

Fixed tests (except webtests); cleaned up Example{Studies,Templates}.groovy; decapitalized injected services; made 'transactional' properties static

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r1585 r1588  
    694694        }
    695695
     696    // This closure is used in the before{Insert,Update,Delete} closures below.
     697    // It is necessary to prevent flushing in the same session as a top level
     698    // database action such as 'save' or 'addTo...'. This confuses hibernate and
     699    // produces hard to trace errors.
     700    // The same holds for flushing during validation (but that's not the case
     701    // here).
     702    // http://grails.1312388.n4.nabble.com/Grails-hibernate-flush-causes-IndexOutOfBoundsException-td3031979.html
     703    static manualFlush(closure) {
     704        withSession {session ->
     705            def save
     706            try {
     707                save = session.flushMode
     708                session.flushMode = org.hibernate.FlushMode.MANUAL
     709                closure()
     710            } finally {
     711                if (save) {
     712                    session.flushMode = save
     713                }
     714         }
     715        }
     716    }
     717
    696718        // Send messages to modules about changes in this study
    697719        def beforeInsert = {
    698                 moduleNotificationService.invalidateStudy( this );
     720        manualFlush{cd ..
     721            moduleNotificationService.invalidateStudy( this )
     722        }
    699723        }
    700724        def beforeUpdate = {
    701                 moduleNotificationService.invalidateStudy( this );
     725        manualFlush{
     726            moduleNotificationService.invalidateStudy( this )
     727        }
    702728        }
    703729        def beforeDelete = {
    704                 moduleNotificationService.invalidateStudy( this );
     730                manualFlush{
     731            moduleNotificationService.invalidateStudy( this )
     732        }
    705733        }
    706734}
Note: See TracChangeset for help on using the changeset viewer.