Created
May 31, 2015 15:40
-
-
Save ipolevoy/821e986c5c7deb28a90d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void shouldDeleteOnePatient(){ | |
deleteAndPopulateTables("doctors", "patients", "doctors_patients"); | |
Doctor doctor = Doctor.findById(1); | |
List<Patient> patients = doctor.getAll(Patient.class); | |
a(2).shouldBeEqual(patients.size()); | |
doctor.remove(patients.get(0)); | |
patients = doctor.getAll(Patient.class); | |
a(1).shouldBeEqual(patients.size()); | |
} |
@rivella50, the cached annotations works in such a way that in case, that whenever there is a destructive call like delete something, the framework will drop all associated caches. In this case, it will drop caches for all three tables. The test I wrote above is working as expected, so there must be something in your code. Are you using include() method when loading?
Not anymore!
I will try to create a test class which should demonstrate what is not working correctly.
I'll post the code here when i'm ready
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another option would be to delete an entry in the join table by using the model of the join table.
Then both @Cache statements for Doctor and Patient could stay there :-)