Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @Transactional invalid cases #4551

Merged
merged 13 commits into from
Sep 11, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ List<Audit> find(String owner, String entity, String op) {
}

@Transactional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to add a transaction here, because if the execution fails, the database will not be updated successfully, which is equivalent to automatically rolling back the transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,If there is only one database update I think it can be removed,But I found that he originally added transcation so didn't remove it

void audit(String entityName, Long entityId, Audit.OP op, String owner) {
public void audit(String entityName, Long entityId, Audit.OP op, String owner) {
Audit audit = new Audit();
audit.setEntityName(entityName);
audit.setEntityId(entityId);
Expand All @@ -51,7 +51,7 @@ void audit(String entityName, Long entityId, Audit.OP op, String owner) {
}

@Transactional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. I don't think there is any need to add transaction annotations here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,i think is so

void audit(Audit audit){
public void audit(Audit audit){
auditRepository.save(audit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public boolean isAppNamespaceNameUnique(String appId, String namespaceName) {
return Objects.isNull(appNamespaceRepository.findByAppIdAndName(appId, namespaceName));
}

@Transactional
public AppNamespace createAppNamespaceInLocal(AppNamespace appNamespace) {
return createAppNamespaceInLocal(appNamespace, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void initCreateAppRole() {
}

@Transactional
private void createManageAppMasterRole(String appId, String operator) {
public void createManageAppMasterRole(String appId, String operator) {
Permission permission = createPermission(appId, PermissionType.MANAGE_APP_MASTER, operator);
rolePermissionService.createPermission(permission);
Role role = createRole(RoleUtils.buildAppRoleName(appId, PermissionType.MANAGE_APP_MASTER), operator);
Expand Down