Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default value for CascadeType in Hibernate

Tags:

java

hibernate

I am using Hibernate to persist this bean.

import javax.persistence.*;  @Entity public class Person {     @Id @GeneratedValue     private int id;     @Column     private String name;     @OneToOne     private Address addr; } 

What is the CascadeType for addr?

like image 630
wannik Avatar asked Nov 08 '11 09:11

wannik


People also ask

What is default CascadeType?

CascadeType defaults to the empty array . See CascadeType in Annotation Type OneToOne. By default no operations are cascaded.

What is CascadeType in Hibernate?

The cascading types supported by the hibernate framework are as follow: CascadeType. PERSIST : It means that the save() and persist() operations in the hibernate cascade to the related entities. CascadeType. MERGE : It means that the related entities are joined when the owning entity is joined.

What is the default fetch type in Hibernate?

By default, Hibernate uses lazy select fetching for collections and lazy proxy fetching for single-valued associations. These defaults make sense for most associations in the majority of applications.

What is CascadeType refresh?

CascadeType. REFRESH cascades the refresh operation to all associated entities refresh by hibernate session. If one entity is refreshed, other associated entities will also be refreshed if CascadeType. REFRESH is annotated.


2 Answers

CascadeType defaults to the empty array . See CascadeType in Annotation Type OneToOne

By default no operations are cascaded.

like image 87
Sandeep Pathak Avatar answered Sep 24 '22 22:09

Sandeep Pathak


You can check the source of @OneToOne at here . No operations are cascaded by default

  /**      * (Optional) The operations that must be cascaded to       * the target of the association.      *      * <p> By default no operations are cascaded.      */    CascadeType[] cascade() default {}; 

Read more: http://kickjava.com/src/javax/persistence/OneToOne.java.htm#ixzz1d6ZWMM2y

like image 33
Ken Chan Avatar answered Sep 26 '22 22:09

Ken Chan