Vishal,
In business it is all about relationships. When a customer is associated with a product the business receives value. The associations, relationships, Hibernate supports are one-to-one, one-to-many, many-to-many, and many-to-one.
You did not say which one you are using, if they are unidirectional, or if they are bidirectional. Most associations are binary but some are ternary where an object describes the relationship between two other objects. Simple binary associations of one-to-many and many-to-one are realized in a relational database as foreign key reference between two tables. The binary many-to-many association must be realized in a relational database with a junction table containing foreign keys to the ends of the binary association. The ternary association is realized in a relational database with a junction table containing additional columns describing the association.
Your business object model should reflect the way the business associates its objects not how they must be stored. The only useable data are data loaded into the application. Can you use clothes in your closet? Not until you take them out and put them on. Do you put the clothes on with their hangers attached? Of course not. Then don't do it with your business objects; leave database constructs in the database.
One last thing, make sure the information that is in you objects really belongs to that object. For the courses - students relationship where does the teacher, room number, date-time, and grade belong? To the course? To the student? Or to the association?
Poor performance is not from Hibernate or object associations; it is from sending large object graphs to the presentation tier.
Give more specific information and you will get more specific help.
Dave
|