Change workspace build property programatically : Exception
Hi,
I tried something based on the example code in: https://jazz.net/forum/questions/57335/change-workspace-build-property-programatically?redirect=%2Fforum%2Fquestions%2F57335%2Fchange-workspace-build-property-programatically
IWorkspaceConnection buildWorkspace = ... create new repository workspace ...
UUID uuid = buildWorkspace.getContextHandle().getItemId();
IBuildDefinition definition = ... create new build defintion ...
IBuildDefinition workingDefinitionCopy = (IBuildDefinition) definition.getWorkingCopy();
workingDefinitionCopy.setProperty(IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID,uuid.getUuidValue());
buildClient.save(workingDefinitionCopy, new NullProgressMonitor());
I get the following execption
Exception in thread "main" com.ibm.team.repository.common.InternalRepositoryException: CRJAZ0447I SQL statement execution failed.Integrity constraint violation
SQL: INSERT INTO BUILD.BUILD_DEFINITION (STATE_ID, ITEM_ID, CONTEXT_ID, MODIFIED, MODIFIED_BY_ITEM_ID, ID, PROCESS_AREA_ITEM_ID, JZ_PROCESS_AREA_DISCRIMINATOR) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
SQL Exception #1
SQL Message: Violation of PRIMARY KEY constraint 'BLD_DFNTNPK'. Cannot insert duplicate key in object 'BUILD.BUILD_DEFINITION'. The duplicate key value is (_y76osL8iEeO3SKGeuzsLJg).
SQL State: 23000
Error Code: 2627
Class: com.ibm.team.repository.service.internal.dataaccess.write2.Row
The build definition is created on server but its repository workspace is not properly set.
If I remove the last save command, I get the same result on the server, except I don't get an Exception.