The topic of delaying
SessionFactory creation until some point after startup has come up a few times on the Grails user mailing list so I thought I’d give it a shot. I got it working, but it’s not pretty.
Grails (and Hibernate) will create up to three connections during initialization so the primary focus is to avoid those. In addition the
DataSource will pre-instantiate connections, so we’ll delay those as well.