I’m having an issue where duplicate records are being persisted using GPars. I have a feeling I’m not using GPars correctly. Does anyone see an issue with this example? This thread suggested using withNewSession
, but I'm still seeing the same behavior.
def stageParticipantsForAllSurveys(Map<Survey,List<Participants>> surveys){
GParsPool.withPool(15){
surveys.eachParallel { survey, participants ->
buildSurveyRoster(survey, participants)
}
}
}
def buildSurveyRoster(survey, participants){
GParsPool.withPool(5){
participants.eachParallel{ participant ->
stageParticipant(survey, participant)
}
}
}
def stageParticipant(survey, participant){
Participant.withNewSession{
new Participant(name: participant.name, surveyId: survey.id).save()
}
}