Grails domain class creation from database

可紊 提交于 2019-12-08 02:22:01

问题


I would like to create grails domain classes from an existing database, normally i was creating database from domain classes now i need to create it from an existing database schema. Please help me if there is any command available for that.


回答1:


I'm on the same problem and I've found this Grails plugin: http://grails-plugins.github.com/grails-db-reverse-engineer/docs/manual/guide/single.html. It works perfectly: it inspects the existent database and creates domain classes, all ready to go. Just follow the steps showed in the example and you're done.




回答2:


There is a tool called GRAG: http://grag.sourceforge.net

Perhaps this might help.




回答3:


  • add plugin (runtime ':db-reverse-engineer:3.0.0') in buildconfig.groovy
  • Change Hibernate version from hibernate4:4.3.6.1 to hibernate:3.6.10.18
  • Define package config in config.groovy to generate domain class grails.plugin.reveng.packageName="com.app.promotion"
  • List the tables, you want to generate domain classes in config.groovy grails.plugin.reveng.includeTables=["promotion","event","promotionexecutionstrategy"]
  • Define the shcema config in config.groovy grails.plugin.reveng.defaultSchema=”t0006”
  • Then execute the command “grails -Dgrails.env=development db-reverse-engineer”. Here development is the environment in the datasource.
  • After complete these steps we can see the domain classes in the package as we defined list items.


来源:https://stackoverflow.com/questions/5454897/grails-domain-class-creation-from-database

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