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

Update item will set DeletedAt timestamp #4492

Closed
3 tasks done
nobodyiam opened this issue Jul 30, 2022 · 2 comments · Fixed by #4493
Closed
3 tasks done

Update item will set DeletedAt timestamp #4492

nobodyiam opened this issue Jul 30, 2022 · 2 comments · Fixed by #4493

Comments

@nobodyiam
Copy link
Member

  • I have checked the discussions
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Describe the bug
After the item is updated, the item's DeletedAt field will be set.

To Reproduce
Steps to reproduce the behavior:

  1. Add a new configuration item - a=1, the data in Item table is:
Key Value IsDeleted DeletedAt
Item 1 0 0
  1. Update the value to 2, the data in Item table is:
Key Value IsDeleted DeletedAt
Item 2 0 1659181295058

Expected behavior

The DeletedAt field should be 0 if IsDeleted is 0.

Additional Details & Logs

  • Version: 2.0.1
@nisiyong
Copy link
Member

Why updating items will trigger com.ctrip.framework.apollo.common.entity.BaseEntity#setDeleted ?

@nobodyiam
Copy link
Member Author

It's because of the statement - BeanUtils.copyEntityProperties(item, managedItem);.

@Transactional
public Item update(Item item) {
checkItemValueLength(item.getNamespaceId(), item.getValue());
Item managedItem = itemRepository.findById(item.getId()).orElse(null);
BeanUtils.copyEntityProperties(item, managedItem);
managedItem = itemRepository.save(managedItem);
auditService.audit(Item.class.getSimpleName(), managedItem.getId(), Audit.OP.UPDATE,
managedItem.getDataChangeLastModifiedBy());
return managedItem;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants