Could please anybody explain what are pros and cons of this? I mean, without using ORM framework/JPA specification.
It concerns many-to-many and many-to-one relationships between entities. Imagine entity relationship
teacher - student (many-to-many)
or
doctor - patient (one-to-many)
My question is, whether we could put getPatients() method at Doctor bean or getStudents() at Teacher bean, or whether it should be POJOs and all this stuff should be placed in DAO layer.
I often see the first approach to be used in cases where the object model beans either extend classes that supply them with access to service / persistence Facades, or are injected by spring with them etc. It's advantage is, that one can call doctor.getPatients(); practically everywhere in the application instead of getting the results from DAO.
Are there situations in which the first approach is handy? Because I see a lot of cases where it is done exactly like that and I'm wondering whether it has a purpose or it is amateurism or the old style.