What is the use of cascade in hbm file?

Editorial / Best Answer

anupsadhwani60  

  • Member Since Sep-2007 | Sep 16th, 2007


1) cascade="none", the default, tells Hibernate to ignore the association.
2) 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.
3) cascade="delete" tells Hibernate to navigate the association and delete persistent
instances when an object is passed to delete().
4) cascade="all" means to cascade both save-update and delete, as well as
calls to evict and lock.
5) 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).
6) cascade="delete-orphan" Hibernate will delete any persistent entity
instance that has been removed (dereferenced) from the association (for
example, from a collection).

Showing Answers 1 - 18 of 18 Answers

suji

  • Apr 23rd, 2007
 

If cascade=all
It loads all related data

  Was this answer useful?  Yes

kasi.sriram

  • Aug 31st, 2007
 

The use of configuring 'cascade=all' for a particular attribute of a POJO is all the db queries (Save,Update,Delete and Select) against a POJO will always apply to this particular attribute also and no need to execute seperately for this attribute.

Regards,
Kasi.

  Was this answer useful?  Yes

1) cascade="none", the default, tells Hibernate to ignore the association.
2) 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.
3) cascade="delete" tells Hibernate to navigate the association and delete persistent
instances when an object is passed to delete().
4) cascade="all" means to cascade both save-update and delete, as well as
calls to evict and lock.
5) 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).
6) cascade="delete-orphan" Hibernate will delete any persistent entity
instance that has been removed (dereferenced) from the association (for
example, from a collection).

padmasri_p

  • Nov 1st, 2007
 

cascade specifies which operations should be casecaded from the parent object to the associated object. The meaningfull values would be persist , merge, delete, save_update, evict , replicate, lock , refresh , all , delete_orphan.

  Was this answer useful?  Yes

Whenever we have a parent child relation ship, if parent record is changed then child record should also be changed.

Primary key must be reflected in the child key

  Was this answer useful?  Yes

venkat

  • Jan 22nd, 2013
 

Using cascade property we can ensure relationship with parent to child

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions