Grails:Domain Design Via Intellij Idea’s Diagrams

23 / Nov / 2011 by Hitesh Bhatia 0 comments

Here is an example of how to design Grails domain class with Intellij Idea.For this we need to have blank domain classes. So lets say we created  three Domain Classes Company,Book,Author

  1. To see relationship diagram, Selected Domain Class, and selected tab Domain Class Dependencies.It should look like this
  2. Lets assume the relation that publication has many books. So I drag mouse from Company to Books. Which invokes a popup asking about relationship between the domains and type and name of the field.
  3. On Selecting ok from previous popup. Their relation is defined in domain and in diagram. Similarly, lets define
    1. Book hasMany Authors,
    2. Authors hasMany Books,
    3. Book belongsTo Author
    4. And Diagram looked like this.
  4. Next Step – Lets add fields to Domain Class all by Intellij Idea’s UI. Select package of domain class and pressshft+ctrl+alt+u. It’ll open package diagram of app.
  5. Now lets add field name to domain Author. For that we’ll need to select domain author,right click and select fields. It’ll invoke a popup asking details about field.

    Similarly we add field name to Author and published on to Book.

  6. Now lets add a method to named “publishedBefore” to Book which takes a date and return list of books published before that date.For this we need to right click on domain and select method.And it’ll invoke popup asking details.Select create and its done.

This was a simple and easy way to create structure of grails app in Intellij Idea.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *