Skip to content

Commit

Permalink
Use withNewSession
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Scott Brown committed Dec 24, 2017
1 parent 2fba8d1 commit 3b7f747
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/groovy/com/foo/utils/EntityInitializerUtils.groovy
Expand Up @@ -20,7 +20,7 @@ class EntityInitializerUtils {
// @Transactional
void initializeDomains() {
Map configuration = [
// 'hibernate.hbm2ddl.auto':'create-drop',
'hibernate.hbm2ddl.auto':'create-drop',
// 'hibernate.enable_lazy_load_no_trans':false,
'dataSource.url':'jdbc:h2:mem:myDB',
// 'dataSource.pooled':true,
Expand All @@ -30,6 +30,9 @@ class EntityInitializerUtils {
]
HibernateDatastore datastore = new HibernateDatastore( configuration, User)

println User.count()
// This is just one way to handle the situation...
User.withNewSession {
println User.count()
}
}
}

0 comments on commit 3b7f747

Please sign in to comment.