PDA

View Full Version : Question to findAll



typo
Sep 12th, 2010, 12:51 PM
Hello,

I'm currently doing an app to reserve meals online. I have following domain classes:



class Meal {

static hasMany = [mealitems : Mealitem]
Date date
String title
}





class Mealitem {

int id
String text
float price
String imageUrl
}




class Orders {

User user
Meal meal
Date created
static hasMany = [mealitems : Mealitem]
}



I can do orders, that works out perfectly well. But when I want to display all my orders, I need to show the meal and my ordered items.

By:


def user = User.findByEmail("doe@example.org")
def orders = Orders.findAllByUser(user)
[orders : orders]


this shows me my ordered meals BUT all its items - I just want my ordered ones.

How can I do that?
Thank you very much.

Best,
Silavn

pledbrook
Sep 23rd, 2010, 05:09 PM
Sorry, I don't understand the question. What's the problem? Also, why does an order have both a meal and meal items when the meal also has meal items? Is that duplication of information?