If I were to choose among the two, I would certainly opt for the first solution. I see absolutely no merit in passing a Teacher
object with an empty list of Student
s along with a separately populated free-standing list of Student
s, as opposed to passing a Teacher
object with its own list of students already populated.
However, if it was up to me, I would not choose either of these two approaches.
Keep in mind that the fact that the teacher has a list of students is an elaborately constructed and maintained illusion that your persistence layer provides you with. From a relationally normalized point of view, the teacher does not actually have a list of student; instead, either each student has a teacher, or, if a student may need to have many teachers, then this is realized by means of a many-to-many relationship.
The many-to-many relationship is implemented as an extra table containing rows with pairs of just teacher ids and student ids. In this case, the illusion of a collection applies to students, too: a student may have a list of teachers just as easily as a teacher may have a list of students. So, when you create a student, why not create them with their list of teachers already filled in? Clearly, this is absurd, so I think that the whole idea of creating entities with pre-filled-in relationships is absurd.
So, what I would do is that I would instantiate and pass around separate teacher entities and student entities, (without any pre-filled-in relationships among them,) and then in separate steps I would specify the relationships among them on an individual basis.