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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:56:21+00:00 2026-06-13T12:56:21+00:00

In my app, the user makes a search. That search gives back a list

  • 0

In my app, the user makes a search. That search gives back a list of people that can be hired for a duty. But, user can make more than one search for the same duty (say, i need two persons for this city, and three for that city). Every search makes a “Prepresupuesto”, and every Prepresupuesto makes a “Cocontrato”. All “Cocontrato” makes a “Contrato”, and all “Prepresupuestos” makes a single “Presupuesto”. And all together conforms the entire duty, called “Campaign” in the app.

When i am trying to save that “Cocontrato”, I receive the exception. This is the code:

ArrayList<Prepresupuesto> prepresus=Prepresupuesto.findAllByCamp(campid)

        Presupuesto pres=new Presupuesto()

        for(int i=0;i<prepresus.size();i++){

            pres.prepresu.add(prepresus[i])

            pres.camp=Campaign.get(prepres.camp.id)

            pres.estado="Pending"

            total=total+prepresus[i].total

            crearCocontrato(prepresus[i])
            }

Method crearCocontrato():

public crearCocontrato(Prepresupuesto prep){
    Set <Azafata>azas=prep.azafatas
    Cocontrato cocon=new Cocontrato()
    cocon.contrato=con
    cocon.precio=prep.precio
    cocon.azafatas=azas
    cocon.total=prep.total
    cocon.horas=prep.horas
    cocon.horario=prep.horario
    cocon.localidad=prep.localidad
    cocon.fechaInicio=prep.fechaInicio
    cocon.fechaFin=prep.fechaFin
    cocon.presu=prep
    cocon.camp=prep.camp



    if(!(cocon.save(flush:true))){
        render (view:"fallos", model:[azafataInstance:cocon])

    }
}

The Exception is launched in the if.

Any help? I am a bit lost, I am a newcomer to Grails, and I think i don’t understand completely the exception.

Thank you!

EDIT: The Exception:

Found shared references to a collection: com.publidirecta.Cocontrato.azafatas.     Stacktrace follows:
Message: Found shared references to a collection: com.publidirecta.Cocontrato.azafatas
Line | Method
->> 2448 | crearCocontrato in com.publidirecta.EntidadController$$ENmku0D2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   2394 | boton           in     ''
|    886 | runTask . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
|    908 | run             in     ''
^    680 | run . . . . . . in java.lang.Thread
  • 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-13T12:56:22+00:00Added an answer on June 13, 2026 at 12:56 pm

    You’re probably trying to save more than one entity (cocon) when both refer to the same collection. It’s hard to detect that in this code you posted and it could be somewhere else, but I would say it’s when you do this:

    Set <Azafata>azas=prep.azafatas
    cocon.presu=prep
    

    Then when you save cocon, it points to the same collection that prep does. Take a look at this link, that says the same thing.

    A way out of this would be to add element by element to the list you want to copy to instead of sharing the reference by doing a.list = b.list.

    This can also help you.

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

Sidebar

Related Questions

I want to make search module just like android keypad that gives the list
I have a small app, where user can make some calculations and solve equations.
I would like to make my app freeware, but if a user is willing
In my app,user can select image from gallery and after that he can zoom
I want to make the user of the app I'm developing, able to load
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I have a simple address book app that I want to make searchable. The
I need to make a web app that I would be able to install
My app is just a DB where the user just search some scientifical data.

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.