Fix entityManager.merge for ds and sm (#2602)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -1982,10 +1982,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andExpect(jsonPath("$._links.start.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/start"))))
|
||||
.andExpect(jsonPath("$._links.pause.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/pause"))))
|
||||
.andExpect(jsonPath("$.dynamic", equalTo(isDynamic)))
|
||||
.andExpect(
|
||||
jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
||||
.andExpect(jsonPath("$._links.groups.href",
|
||||
allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
||||
.andExpect(jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
||||
.andExpect(jsonPath(
|
||||
"$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
||||
}
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
|
||||
@@ -728,7 +728,13 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
// implicitly lock, for some reason no update happen if lock in same transaction
|
||||
distributionSet = DeploymentHelper.runInNewTransaction(
|
||||
txManager, "lockDistributionSet-" + dsId,
|
||||
status -> distributionSetManagement.lock(dsValidAndComplete));
|
||||
status -> {
|
||||
if (entityManager.contains(dsValidAndComplete)) {
|
||||
return distributionSetManagement.lock(dsValidAndComplete);
|
||||
} else {
|
||||
return distributionSetManagement.lock(entityManager.merge(dsValidAndComplete));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
distributionSet = dsValidAndComplete;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class JpaDistributionSetManagement
|
||||
|
||||
private JpaDistributionSet toJpaDistributionSet(final DistributionSet distributionSet) {
|
||||
if (distributionSet instanceof JpaDistributionSet jpaDistributionSet) {
|
||||
return entityManager.merge(jpaDistributionSet); // if from
|
||||
return jpaDistributionSet;
|
||||
} else {
|
||||
return getById(distributionSet.getId());
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class JpaSoftwareModuleManagement
|
||||
|
||||
private JpaSoftwareModule toJpaSoftwareModule(final SoftwareModule softwareModule) {
|
||||
if (softwareModule instanceof JpaSoftwareModule jpaSoftwareModule) {
|
||||
return entityManager.merge(jpaSoftwareModule); // if from
|
||||
return jpaSoftwareModule;
|
||||
} else {
|
||||
return getById(softwareModule.getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user