I've recently started looking into Hibernate. I've searched for best practices regarding the layer of the Hibernate related classes and one thing that always comes up is the following structure: Each Entity has its own DAO Interface, which in turn has its own DAO implementing class, which in turn has its own Service.
Is this considered to be the best practice? My problem with that is that a lot of code is being repeated or is basically the same for every entity. And frankly, 4 files for each model seems a bit too much to me.
I understand how interfaces for DAOs make changing frameworks and testing easier. And I agree that on some of them you need separation between the DAO and the service (as you want to keep DAO functionality to a minimum and add additional business logic in the service).
But some entities need only simple logic, and the DAO is more than enough for them. Should they still have their own service class? And what if a good number of entities will always need the same basic functionality? Can't their DAOs share a common interface? (instead writing one for each of them)
In conclusion, wouldn't an adaptive approach to each entity fit better or would that break the predictability of the code?