I have a very simple service set up to create an entry in a Postgres table, and I use it in Bootstrap.groovy for my Grails 3 web-app.
// CompanyService
public Company createCompany(String name) {
Company company = new Company(name: name)
company.save()
return company
}
// BootStrap
def init = {
companyService.createCompany('My Company')
}
Well, at startup I cannot see My Company
entry, no matter if the service is transactional or not.
Instead, if using the same line for example in a controller, it works as expected. Am I missing something here?
Have you called your service inside
bootstrap
?