问题
I'm writing a Grails application that will be pulling data from an existing Oracle database. If I were designing this from scratch I could hold all the information in two or three domain models because logically that's how the data should be arranged. However, this is a pre-existing database that has the data I need spread across approximately 25-30 tables. So I am wondering which of the following approaches would be considered best. I don't want to do tons of extra work to take advantage of what Grails has to offer, but at the same time I'd like to take advantage of as much of Grails as possible.
- Create domain models for all 25-30 tables and then gather the data into two or three classes.
- Create the two or three domain models and populate them "manually" with SQL calls
- Since I'm new to Grails and how it handles data, something else that I haven't thought of yet.
回答1:
There is one answer to all of your queries:
database-reverse-engineer plugin
You can configure the way you want to reverse engineer the tables to domain classes. Refer docs as well.
来源:https://stackoverflow.com/questions/21395553/grails-best-approach-to-dealing-with-an-existing-database