Hibernate: Cascade Type

后端 未结 3 1343
情话喂你
情话喂你 2020-12-13 20:55

Let\'s I have entity A and entity B. Entity A have @OneToOne relationship with B.
I want do next:
if

3条回答
  •  悲&欢浪女
    2020-12-13 21:25

    If Class A has Class B then CascadeType.ALL will be appiled on B. then

    Public Class A
    {
      Private B b;
      @OneToOne(cascade = CascadeType.ALL)   
      public B getB() {       
        return this.b;   
       }     
      public void B(B b) {         
        this.b = b;   
      }
    }
    

    for more read this example

提交回复
热议问题