0

I'm trying Grails 3.0.8 for the first time. I'll use it to create web-services for mobile development.

I already have a mysql database with a lot of tables. I found that I can use "db-reverse-engineer:0.5.1" to generate the different domains from the tables. For some reason, I cannot install the plugin and it doesn't work. I think it has something to do with the new version of Grails which is 3.0.8.

As there are not a lot of documentation on this version, I was wondering if there was a way to generate domains from an existing MySQL database.

If not, is it possible to use the database without having to create domains for the tables?

mokko211
  • 537
  • 2
  • 9
  • 24

1 Answers1

0

The db-reverse-engineer plugin is for Grails 2. It's not compatible with Grails 3. See Grails 3 reverse engineer database to domain objects

You can run database queries if you get a Hibernate session. You can read about how to get one here.

With a Hibernate session, you can use the Session.createQuery(String) method to create a SQLQuery instance. Then just execute the SQLQuery.list() method to run the query. Here's an example of running an arbitrary query in an H2 database.

def q = session.createSQLQuery 'select * from INFORMATION_SCHEMA.COLUMNS'

q.list() // Runs the query.
Community
  • 1
  • 1
Emmanuel Rosa
  • 9,167
  • 2
  • 10
  • 18