I am in development phase, trying to use in-memory DB and load it with some data during Grails application start up. My question is, is there any way to write/configure SQL insert statements that can be executed during startup.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this in BootStrap.groovy. If you add a dependency injection for the
dataSourcebean you can use it with agroovy.sql.Sqlinstance to do inserts:You would probably be better off using GORM though, assuming these are tables that are managed with domain classes. E.g. run something like
new Book(author: 'me', title: 'some title').save()