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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:17:53+00:00 2026-06-07T12:17:53+00:00

I am building a grails application with domain classes whose id generator is assigned

  • 0

I am building a grails application with domain classes whose id generator is assigned (that is, they do not auto-generate). Assume I have a domain class Parent with static hasMany = [children: Child] and domain class Child.

I am trying to locate an instance of Parent using Parent.findWhere(propertyMap), but am getting a NonUniqueObjectException indicating that there is already a Child instance associated with this session having id 0. My propertyMap does not contain an entry for id.

Now, I am used to getting this error any time I try to save two instances of one class in a session without setting their ids. Because ids are not auto-generated, they default to zero, which allows the first to be saved, and the second throws an error, as the id is a duplicate of the first. What is surprising me here is that I am trying to find an instance, not save one… Does anyone know what might be causing this behavior and how I can get around it while still searching using my property map?

  • 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-06-07T12:17:55+00:00Added an answer on June 7, 2026 at 12:17 pm

    It turns out this was a groovy syntactical sugar problem. I was calling findWhere like

    Parent.findWhere([ firstProperty: "firstValue", secondProperty: "SecondValue" ])
    

    but apparently I should be using

    Parent.findWhere( firstProperty: "firstValue", secondProperty: "SecondValue" )
    

    (note the lack of square brackets). I don’t know why this made a difference, but findWhere works as expected now. Extra points to anyone who might know why it behaves like this.

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

Sidebar

Related Questions

We have an application in Grails 2.0 that we have working when we run
Im building a Grails app that will have multiple similar websites (each it's own
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I'm currently building a grails application with grails 1.3.7 (IDE: IntelliJ Ultimate 10.5), and
So I’m new to grails and I am building a help desk application. The
I'm building out a Grails app and realize that a lot of custom stuff
Building a stand alone WPF application that uses a MSSQL backend. I would like
I'm building an application that among other things allows users to upload documents. I
I'm building a web application with Grails, using the Acegi/Spring Security plugin. I want
I am building a web application using Grails. I decided to use dojo and

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.