1) Create a method in service layer, which finds all the objects from the table with a Repository and checks with "if" sentences the operation type. For example: If its an ADD, call the Repository method add(Object);I don't see why - frankly, if there are really not much more than 3 types of operations, and the list is not likely to change in the future, Strategy is overkill!
I dont like the several if sentences
and there is no business logic in the Entity.So what? You don't have to put BL in Entity classes.
2) Create an Entity which uses strategy pattern with operation type.I don't know, is there a way in JPA to map a given table to several classes of a given hierarchy? Because if not, then the Entity classes would not be the Strategy classes, instead you would have a single Entity class that delegate to an instance of a Strategy class. The problem is then how to select the appropriate strategy? Using if(..)s? :o) Back to it below...
I dont know how to call the add/delete/update method from the repository in the strategy, unless the entity see the repository (is this good?).