Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to structure domain objects

 
Daniel Dalton
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this isn't too dumb a question, and this looks like the best forum to post it in, even though everone's talking about Hibernate etc...

I have a series of Relational tables as follows:

Person, Accident, Visit, and various Treatment tables.

A person may have multiple accidents, each of which may be associated with multiple Visits, each of which may have several different associated Treatments.

I've associated a simple POJO with each table, and I have a DAOFactory which can produce DAOs for each type of object. I've tried to keep the DAO's cohesive - so each only knows about it's associated POJO.

Now I'm really not sure how best to relate the objects to each other. should a Person contain a List of Accidents? Should the PersonDAO invoke the AccidentDAO to load them? Should I be trying to load a whole object graph from the database when I load a patient? I'm sure I'm missing something because it doesn't feel quite right.

Any ideas?
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
daniel

you no need of calling the DAOS seperately

for Person as well as Accidents

you can establish the relationship in mapping file

proper use of inverse and cascade attributes in set tag

can releive you form these problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic