The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

emaayan (1) [Avatar] Offline
hi..have a model which among other stuff has

a Policy, which includes several Plans, and these several Plans refer to a single (or many) of AssuredPersons.

somwhere in the model i'll have an AssuredPerson which maintains a list of plans (which may be included in several policies).

all these classes needed to be persisted in hibernate so natrually they will have geter and setters for their primitive data. as well as being populated with data from another module someone else is writing

my questions is, do i need to create a seperate class which will provide methods for attaching each class to one another (for example plan to Policy).
this means that the getters and setters that each class holds for it's parent (for example the Class Plan has a setter for Policy) will have to be at package level, so no-one outside the package will use it, will this be a problem for hibernate?

or should add this functionality to the classes themselves.

for example:
Policy will have addPlan method which will accept Plan class, and a person class, and inside will aggregate the person to a central person List.
ceracm (113) [Avatar] Offline
Re: dividing responsabitlies in a model?
My guess is that the behavior should go in the classes themselves.

class Policy {
List<Plan> plans;

void addPlan(Plan plan, Person person) {

Not sure what you mean by "and inside will aggregate the person to a central person List. " though...