How Many, Which Direction And Who Is The Owner

In modeling Hibernate objects you need to know the object navigation, cardinality and ownership.

In database you can navigate the records using primary/foreign key relationship. In Hibernate you need to explicitly define navigation in the form of properties during the modeling unless you want to use Query interface.

Cardinality defines an entity can relate how many other entities or itself (in database, parent/child relationship in the same table). In Hibernate you can define them using List (allow duplicates), Set (no duplicates) or only one entity as property.

The ownership defines which entity (table in the database) has the foreign key. If the entity A cannot be created without another object B existence then A should be owner of the relationship. If you think in the database terms, if you try to insert a record in a table and that record requires a foreign key, it is the owner table and the entity represents that table must be owner of the relationship.

Advertisements
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s