Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4570784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:24:41+00:00 2026-05-21T19:24:41+00:00

Originally posted on the Grails mailing list… I’m not generally a database guy but

  • 0

Originally posted on the Grails mailing list…

I’m not generally a database guy but with the release of the latest mongodb plugin for grails, I wanted to see what the big deal is with noSQL databases. MongoDB seems pretty interesting. I was reading the information on Document oriented storage and came across the following scenario:

Customer / Order / Order Line Item

The doc says orders should be a collection. customers a collection. line-items should be an array of line-items embedded in theorder object.

With regards to GORM, how is this pattern ensured? I’d typically have the following:

class Customer {
    static hasMany = [orders: Order]
}

class Order {
    static hasMany = [orderItems: OrderItem]
    static belongsTo = [customer:Customer]
}

class OrderItem {
    static belongsTo = [order:Order]
}

How do I make sure that Orders is its own collection and not embedded within Customer? If that is the default, how to I make sure that OrderItems are embedded in Order and not it’s own collection? What is the default here?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:24:42+00:00Added an answer on May 21, 2026 at 7:24 pm

    From reading the Grails MongoDB Plugin documentation, it seems like you need to specifically declare embedded objects, with references being the default.

    With that in mind, if you want to make sure that Orders to be its own collection, and OrderItems to be embedded, try this:

    class Customer {
      List<Order> orders
    }
    
    class Order {
      List<OrderItem> orderItems
      static embedded = [ 'orderItems' ]
    }
    
    class OrderItems {
      // properties go here.   
    }
    

    Here’s the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[originally posted on Symfony forum but no (proper) answer has been given yet]. Has
This is originally posted as an answer to c++ macros with memory? But somehow
I originally posted this question over at the Zend Forums but figured it would
Note: I originally posted this on ServerFault, but I haven't gotten any responses at
I originally posted this queston on coderanch, but I didn't get responses, so I
Originally posted on Server Fault , where it was suggested this question might better
Note this question was originally posted in 2009, before C++11 was ratified and before
Update I don't think I was clear enough when I originally posted this quesion.
Originally posted on: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21355401.html I have a solution containing two projects: a webservice project
I originally posted a question here I've discovered that the JTextField only resizes if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.