You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a BeanPersistAdapter with a preDelete method. The BeanPersistAdapter is registered for class "A", which has a M2M relation to class "B" with CascadeType.REMOVE. Now "A" references four objects of "B".
Expected behavior
The preDelete() method of the "A"BeanPersistAdapter should contain a list with four objects of "B".
Actual behavior
The List is empty.
Steps to reproduce
I also tested this with the ebean test models (MnyB and MnyC):
Create a MnyBPersistAdapter.
publicclassMnyBBeanPersistAdapterextendsBeanPersistAdapter {
@OverridepublicbooleanisRegisterFor(Class<?> cls) {
returnMnyB.class.isAssignableFrom(cls);
}
@OverridepublicbooleanpreDelete(BeanPersistRequest<?> request) {
if (((MnyB) request.bean()).getCs().isEmpty()) {
System.out.println("MnyB contains zero elements of MnyC.");
} else {
System.out.println("MnyB contains elements of MnyC.");
}
returntrue;
}
}
Create a MnyB object and add a MnyC object to the M2M reference.
@Testpublicvoidtest() {
MnyBmnyB = newMnyB();
MnyCmnyC = newMnyC();
mnyB.getCs().add(mnyC);
DB.save(mnyC);
DB.save(mnyB);
MnyBmnyBFromDB = DB.find(MnyB.class, mnyB.getId());
// The preDelete of the BeanPersistAdapter should contain one object of MnyC.assertThat(mnyBFromDB).extracting("cs").isEqualTo(List.of(mnyC));
DB.delete(mnyBFromDB);
}
The test runs green and the console shows the following output:
MnyB contains zero elements of MnyC.
Tell me if I'm wrong, but I think that the list of MnyC reference objects should not already be emptied in the PreDelete().
I am looking forward to your opinion.
Thanks,
Wosch
The text was updated successfully, but these errors were encountered:
We have a BeanPersistAdapter with a preDelete method. The BeanPersistAdapter is registered for class "A", which has a M2M relation to class "B" with CascadeType.REMOVE. Now "A" references four objects of "B".
Expected behavior
The preDelete() method of the "A"BeanPersistAdapter should contain a list with four objects of "B".
Actual behavior
The List is empty.
Steps to reproduce
I also tested this with the ebean test models (MnyB and MnyC):
Create a MnyB object and add a MnyC object to the M2M reference.
The test runs green and the console shows the following output:
MnyB contains zero elements of MnyC.
Tell me if I'm wrong, but I think that the list of MnyC reference objects should not already be emptied in the PreDelete().
I am looking forward to your opinion.
Thanks,
Wosch
The text was updated successfully, but these errors were encountered: