• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to structure domain objects  RSS feed

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?
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!