Grails: Best approach to dealing with an existing database

故事扮演 提交于 2020-01-03 13:56:28

问题


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.

  1. Create domain models for all 25-30 tables and then gather the data into two or three classes.
  2. Create the two or three domain models and populate them "manually" with SQL calls
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!