Hi all,
I use Hibernate for a short period of time and now I'm facing a complex problem. I try figure it out what is the best practice for the following scenario:
I have the following classes: Department, Team, Position, all of them inherited from a Entity class even there is almost no difference between them. But I wanted different classes for different entities.
I try to create a tree hierachy, each object is with all others in a bidirectional one-to-many relationship. For example a Department can have Teams and Positions as children and a Position can have Departments and Teams as children.
I created the mapping files and I loaded the tree without problems. But I cannot user general methods because in every moment I have to know the type of the parent and the type of the child in order to call the proper method for save/update/delete.
How can I avoid this and implement a more general way to work with this relationships in the tree?
What is the best approach for this issue?
Thanks.
|