default value for CascadeType in Hibernate

JavaHibernate

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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

> By default no operations are cascaded.

Solution 2 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwannikView Question on Stackoverflow
Solution 1 - JavaSandeep PathakView Answer on Stackoverflow
Solution 2 - JavaKen ChanView Answer on Stackoverflow