Results 1 to 2 of 2

Thread: Domain Classes in Groovy (Grails App)

  1. #1
    Join Date
    Mar 2017

    Domain Classes in Groovy (Grails App)

    Hi Guys!

    I am a complete novice in Grails. I got intruduced to Groovy, Grails and MySQL for the first time two weeks ago in my CS class.

    For an assignment I must create a Grails-App that handles the interaction with a MySQL DB.
    For this task I must create a Domain Class and Controllers in Groovy.
    I am a bit puzzled as to how many Domain Classes should I have in my App.
    Do I need to create just one for the bigger table or do I have to have a Domain Class for each table?
    I mean the smaller tables are represented with KEYS and ID's in the bigger one. So how do I go about solving this?

    Here is a table with my Database Design:


    I was thinking about doing it this way:

    class Products {
       int  Order
       String  Name
       int  Type_id
       int  Available
       double  Price
       int  Category_id
       int  Origin_id
       int  Production
       String  Delivery
       static constraints = {

  2. #2
    Join Date
    Aug 2004
    Looks like Grails (warning: I know nothing about it, basically) has "has_one" and "has_many" domain methods like Rails does. You would use these to define relationships between a given domain's base DB table and other tables it is related to.

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center