Tutorial about how to use Hibernate from within Groovy making use of Groovy Templating: import javax.persistence.* class JpaTemplate { EntityManagerFactory emf EntityManager em JpaTemplate(pu) { if (!pu) pu = “default” emf = Persistence.createEntityManagerFactory(pu) } void doInEntityManager(c, shutdown) { em = emf.createEntityManager() em.getTransaction().begin() c(em) em.getTransaction().commit() em.close() if (shutdown) shutdown() } void shutdown() { emf.close() } } [...]