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 6119769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:35:28+00:00 2026-05-23T15:35:28+00:00

I’m trying to load a list of Evaluations in a class named Contributor but

  • 0

I’m trying to load a list of Evaluations in a class named Contributor but I’m missing something as I cannot get my test passing.

My test is creating and saving objects as expected because when I do Evaluations.list() and Contributor.list() and print the values I see the data I saved.

Furthermore, when I select an Evaluation and print the value of its ‘contributor’ property it appears to be correct.

However, when I select a Contributor and print the values of its ‘evaluations’ property it is null.

I assume my mapping is the problem?

class Contributor {
    String name

    static hasMany = [evals:Evaluation]

    static mapping = {
        id column: 'user_id'
        evals joinTable:[name:'evaluation', column:'eval_id', key:'eval_user_id']
        version false
    }
}

class Evaluation {
    Contributor contributor
    String comment

    static mapping = {
        id column:'eval_id'
        contributor column:'eval_user_id'
        version false
    }
}

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-23T15:35:29+00:00Added an answer on May 23, 2026 at 3:35 pm

    You shouldn’t assign evals like contributor.evals = [eval]. Rather invoke a dynamic method addTo*(): contributor.addToEvals(eval). This will create a Hibernate collection for evals which will be persisted later.

    The first one didn’t work because Grails doesn’t assign other end of association when you assign eval.contributor, i.e. it doesn’t call contributor.addToEvals(eval). I have no idea why – there must be some implementation reason.

    So contributor remains with the same empty evals in Hibernate cache. If it falls out of cache and you re-read it, it will have evals filled, because the association is mapped only on Eval table’s foreign key.

    Empty evals are null – it’s another Hibernate feature: when a collection is empty, it can be null. Just know it.

    Here’s an good short post explaining some Hibernate internals: http://blog.xebia.com/2008/03/advanced-hibernate-proxy-pitfalls/

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.