Tagged: grails groovy db
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by raydawg2000.
-
AuthorPosts
-
raydawg2000ParticipantAre there any plans to implement the current DB reverse engineering tools for Grails applications?
Brian FernandesModeratorThere are no plans to to generate code for Grails applications. Can you give us an example of the output you would like generated? GORM, GORM for Hibernate?
Thanks.
raydawg2000ParticipantHi Brian,
Yes GORM. The reverse engineering for Grails is a little simpler because all that is needed are Domain classes and the framework handles all the hibernate mappings. So for example a DB table called Application would only need a single Domain class instead of a Domain, DAO and XML Mapping file. Here is an example with one-to-many and many-to-one relationshipsclass Application { BigDecimal gpa Date submitDate String appliedFlag String acceptedFlag String deniedFlag String managerNetid Date timeStamp AcademicYear academicYear Quarter quarter Student student Set<ApplicationFile> applicationFiles = [] Set<ApplicationQa> applicationQas = [] Set<ApplicationAccepted> applicationAccepteds = [] Set<ApplicationDenied> applicationDenieds = [] static hasMany = [applicationAccepteds: ApplicationAccepted, applicationDenieds: ApplicationDenied, applicationFiles: ApplicationFile, applicationQas: ApplicationQa] static belongsTo = [AcademicYear, Quarter, Student] static mapping = { version false quarter column: "quarter_code" student column: "sid" applicationAccepteds cascade: "save-update, delete-orphan" applicationDenieds cascade: "save-update, delete-orphan" applicationQas cascade: "save-update" } static constraints = { submitDate nullable: true appliedFlag maxSize: 1 acceptedFlag maxSize: 1 deniedFlag maxSize: 1 managerNetid nullable: true, maxSize: 36 } }
There used to be a plugin for Grails that had this functionality and uses the hibernate-tools library but it stopped being maintained a while ago and the newer Grail releases are not compatible. I figured since MyEclipse uses the same hibernate-tools to generate Java code that maybe it would be possible to expand on that to generate Grails domain classes?
http://grails-plugins.github.io/grails-db-reverse-engineer/grails3v4/index.html
Brian FernandesModeratorRay,
I thought I had replied earlier, apologies.
Thank you for taking the time to provide the example – gives us a better understanding of what you’d like implemented. The fact that the Grails plugin depends on hibernate-tools will make it easier, but it is still a non trivial task.
I’ll file this with your details, but to be upfront I don’t see this as something our team will be able to get to in the near future.
Thank you for sending in the request.
raydawg2000ParticipantUnderstood, thanks for at least submitting the request for me.
-
AuthorPosts