1.

What is the dirty checking feature of Hibernate? Explain?

Answer»

Cascading means when an INSERT, update or delete operation occurs on one ENTITY, its related entities also are inserted, updated or deleted. If cascading is not used, the objects will have to be saved independently and explicitly.

import org.hibernate.annotations.Cascade;  @Entity  @Table(name = "EMPLOYEE")  public class Employee {  @OneToOne(mappedBy = "employee")  @Cascade(value = org.hibernate.annotations.CascadeType.ALL)  public Department dept;  }

The CascadeTypeenum constants of Hibernate are slightly different from JPA. As shown in the above example, we use. CascadeType and Cascade annotations for mappings. The commonly used cascading types as DEFINED in CascadeTypeenum are: 

  1. NONE: There is no cascading as no cascading is defined. This means that operations in the parent do not affect the child. 
  2. ALL: This includes all the cascade types i.e. save, delete, update, evict, lock, replicate, merge and persist. This also means that any operation on the parent will affect the child as WELL 
  3. SAVE_UPDATE: Available only in hibernate. Includes the Cascade save and update 
  4. DELETE: This type corresponds to the Hibernate native DELETE action. 
  5. DETACH, MERGE, PERSIST, REFRESH and REMOVE – These also correspond to similar Hibernate native actions 
  6. LOCK: Also corresponds to the Hibernate native LOCK action. 
  7. REPLICATE: This also corresponds to the Hibernate native REPLICATE action. 


Discussion

No Comment Found