I'm wondering if I'm not mistaken, I've read, seen, or even implemented something like this but I can not remember it, it's the following:
I have here an EJB project with several entities, some of them have very similar ways of saving, for example the Contract and Financial Aid entity, these two (and more others) will implement a list of Competencies and save other basic attributes. The issue is that so I do not have to implement multiple services and multiple DAOs with the same save methods by changing a little thing here or there I think I could have something like a generic service or dao that took the object from any entity and the entity itself was in charge of saving itself.
We try to do with a Factory that creates the dao corresponding to the type of object passed through but I think it is not there yet ... I do not know for sure but maybe even using dependency injection would be much more elegant ... Someone could give a light?