Hello,
I’m using the standard BulkEditAction. My entity has an association address and a nested property address.zipCode.
Problem :
When I open the Bulk Edit dialog, address.zipCode is not loaded because address is not included in includeProperties (so it is not part of the Bulk Edit fetch plan).
As a result, during save, address.zipCode becomes null in my BeforeSave/EntitySavingEvent validation.
I have business logic that checks the zip code, so the save fails although the zip code was already filled before opening Bulk Edit.
How can I add address in the Bulk Edit fetch plan without making it editable?
Thanks!
Hello!
Bulk Edit dialog reloads selected items and for association attributes uses instance_name fetch plan. So address.zipCode should not be loaded.
The EntitySavingEvent event is fired before the transaction commit. So you can load associated entity (address) with your fetch plan an check zipCode.
For instance:
@Component
public class MyEventListener {
@Autowired
private DataManager dataManager;
@EventListener
void onMyEntitySaving(EntitySavingEvent<MyEntity> event) {
MyEntity item = event.getEntity();
Address address = dataManager.load(item.getAddress()).one();
// check address.getZipCode();
}
}