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

  • SEARCH
  • Home
  • 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 6784001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:56:16+00:00 2026-05-26T16:56:16+00:00

I have the following piece of code in ItemController.groovy def list = { params.max

  • 0

I have the following piece of code in ItemController.groovy

def list = {
    params.max = 60
    def storeYYId = params.id

        [itemInstanceList: Item.list(params), itemInstanceTotal: Item.count()]
}

I have the following in Item.groovy:

class Item {
    String itemName
    static belongsTo = [store:Store]


    static constraints = {
        itemName(blank:false)
        storeId()
    }
}

This gives me an error since it tells me that there is no storeId property, but there is, since store_id is a foreign key to the Store table in the corresponding database.

Question1. How do I tell grails to let me access the properties of domains that are autogenerated by GORM, like the id and storeId in this case?

Question2. What code should I write in my ItemController.groovy in my list action, in order to retrieve only a list of items where the storeId == storeYYId ?

  • 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-26T16:56:16+00:00Added an answer on May 26, 2026 at 4:56 pm

    Question1. How do I tell grails to let me access the properties of
    domains that are autogenerated by GORM, like the id and storeId in
    this case?

    You should be able to access autogenerated properties in exactly the same way as you access properties that you define. The reason you’re getting an error is because Grails does not automatically generate a storeId property for the Item class, the only properties it will autogenerate are version and id (for both Item and Store).

    Question2. What code should I write in my ItemController.groovy in my
    list action, in order to retrieve only a list of items where the
    storeId == storeYYId ?

    You’ll need to write either a HQL or criteria query to retrieve these items. The criteria query would look something like this (untested)

    // Get all items that have storeId = 6
    def storeId = 6
    
    def items = Item.withCriteria {
        store {
            eq('id', storeId)
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code: for i := 0 to FControlList.Count -
I have following piece of code for reversing the linked list. I am getting
I have following piece of code: customObject* object; std::list<customObject> objects; for(int i = 0;
I have the following piece of code: self.ignore_dir_extensions = ['xcodeproj'] item = repr(extension.split('/')[0]) print
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code taken from the PHP manual on the
I have the following piece of code in C++. int arr[] = {1, 2,
I have the following piece of code: // setup the AJAX request var pageRequest
I have the following piece of code from a book. There is this function

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.