tags:

views:

423

answers:

1

For a parent-child entity relationship, when (and why) would you use a DAO interface for only the parent and when would you make also make DAO for the children? To me, it makes sense to only make a DAO for the parent if the Children MUST belong to a parent and should not exist as orphans.

So if I wanted to delete a Child, I would modify the parent's Set of Children, and call parentDAO.update(parent).

Also, in general, is there some good websites/books for Hibernate best practices (ie not learning Hibernate or beginning examples)?

+3  A: 

Whether or not you implement DAOs for child entities depends on your use case. For instance, although a user entity may not exist outside of an account parent, you may wish to rehydrate a user and provide navigability to the parent account.

I found Manning's Hibernate in Action to provide a good 'recipe' type reference for the more advanced stuff.

mysomic