All my entities can not be deleted - only deactivated, so they don't appear in any read methods (SELECT ... WHERE active=TRUE)
.
Now I have some 1:M tables on this entities on which all CRUD operations can be executed.
What is more efficient or has better performance?
My first solution: To add to all CRUD operations:
UPDATE ... JOIN entity e ... WHERE e.active=TRUE
My second solution: Before all CRUD operations check if entity is active:
if (getEntity(someId) != null) {
//do some CRUD
}
In getEntity
there's just SELECT * FROM entity WHERE id=? AND active=TRUE
.
Or any other solution, recommendation,...?