Add wellsamples to well throws ConstraintViolationException
Posted: Thu Mar 14, 2019 3:14 pm
Hello,
I am trying to add several well-samples to a well but get validation error.
Creating the first wellsample with this code is fine and wellsample is inserted in database. But looping it to add other wellsamples for same well throws error.
In documentation https://docs.openmicroscopy.org/ome-mod ... -well.html (under Wellsample) it says that Index should be unique, but I don't see a way to set the index, It seem to be auto-updated by a trigger.
wellsample = omero.model.WellSampleI()
wellsample.setImage(image) # image is referred to via a search for id above
wellsample.well = well # well is created above
wellsample.setPlateAcquisition(plateaq) # plate aq is created above
well.addWellSample(wellsample)
wellsample = conn.getUpdateService().saveAndReturnObject(wellsample)
Error:
serverStackTrace = ome.conditions.ValidationException: could not insert: [ome.model.screen.WellSample]; SQL [insert into wellsample (creation_id, external_id, group_id, owner_id, permissions, update_id, image, plateAcquisition, posXUnit, posX, posYUnit, posY, timepoint, version, well, well_index, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [wellsample_well_well_index_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ome.model.screen.WellSample]
All the best,
Anders
I am trying to add several well-samples to a well but get validation error.
Creating the first wellsample with this code is fine and wellsample is inserted in database. But looping it to add other wellsamples for same well throws error.
In documentation https://docs.openmicroscopy.org/ome-mod ... -well.html (under Wellsample) it says that Index should be unique, but I don't see a way to set the index, It seem to be auto-updated by a trigger.
wellsample = omero.model.WellSampleI()
wellsample.setImage(image) # image is referred to via a search for id above
wellsample.well = well # well is created above
wellsample.setPlateAcquisition(plateaq) # plate aq is created above
well.addWellSample(wellsample)
wellsample = conn.getUpdateService().saveAndReturnObject(wellsample)
Error:
serverStackTrace = ome.conditions.ValidationException: could not insert: [ome.model.screen.WellSample]; SQL [insert into wellsample (creation_id, external_id, group_id, owner_id, permissions, update_id, image, plateAcquisition, posXUnit, posX, posYUnit, posY, timepoint, version, well, well_index, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [wellsample_well_well_index_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [ome.model.screen.WellSample]
All the best,
Anders