Skip to content

Instantly share code, notes, and snippets.

@mirasrael
Last active September 6, 2017 12:44
Show Gist options
  • Save mirasrael/d8a20fe3840ef98fa3ccbcd1405ab5cd to your computer and use it in GitHub Desktop.
Save mirasrael/d8a20fe3840ef98fa3ccbcd1405ab5cd to your computer and use it in GitHub Desktop.
package cv.hibernate
import groovy.transform.CompileStatic
import org.hibernate.engine.spi.SessionImplementor
/**
* Date: 09/05/2017
* Time: 18:30
*/
@CompileStatic
class GormBatchCollectionLoader extends BatchCollectionLoader {
static void preloadCollections(List entities, String ... collectionNames) {
Class entityClass = getEntityClass(entities)
if (entityClass == null) {
return
}
entityClass.getMethod("withSession", Closure).invoke(null, { session ->
preloadCollectionsInternal((SessionImplementor) session, entityClass, entities, collectionNames)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment