Hibernate in action

one to many 中的inverse="true" 表示這是個雙向關聯.需要在另一邊也聲明 many to one.

You can map entity associations in metadata with the following attributes:
■ cascade="none", the default, tells Hibernate to ignore the association.
■ cascade="save-update" tells Hibernate to navigate the association when the
transaction is committed and when an object is passed to save() or
update() and save newly instantiated transient instances and persist changes to
detached instances.
■ cascade="delete" tells Hibernate to navigate the association and delete persistent
instances when an object is passed to delete().
■ cascade="all" means to cascade both save-update and delete, as well as
calls to evict and lock.
■ cascade="all-delete-orphan" means the same as cascade="all" but, in addition,
Hibernate deletes any persistent entity instance that has been removed
(dereferenced) from the association (for example, from a collection).
■ cascade="delete-orphan" Hibernate will delete any persistent entity
instance that has been removed (dereferenced) from the association (for
example, from a collection).

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章