<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                **1. 級操操作** 級操操作是指:操作對象A的同時,也操作該對象關聯的其他對象。 ```java //@OneToOne、@OneToMany、@ManyToOne、@ManyToMany 都有一個屬性 cascade 來控制級聯操作 public @interface OneToMany { //配置級聯操作 //CascadeType.MERGE 級聯更新 //CascadeType.PERSIST 級聯保存 //CascadeType.REFRESH 級聯刷新 //CascadeType.REMOVE 級聯刪除 //CascadeType.ALL 所有級聯操作 CascadeType[] cascade() default {}; } ``` <br/> **2. 使用級聯操作** (1)建立實體類之間的關系。 ```java public class Mother { @OneToMany(mappedBy = "mother", fetch = FetchType.EAGER, cascade = CascadeType.ALL) private List<Children> childrenList; } ``` ```java public class Children { @ManyToOne(targetEntity = Mother.class, cascade = CascadeType.ALL) @JoinColumn(name = "mother_id", referencedColumnName = "id") private Mother mother; } ``` (2)級聯操作。 ```java /************************** Mother -> Children **************************/ /** * 級聯保存/更新。 * 保存/更新 Mother 的同時,也保存/更新 Children 表。 */ @Test public void cascadeSave() { Mother mother = Mother.builder().name("張母").build(); List<Children> childrenList = new ArrayList<>(1); Children children01 = Children.builder().name("張三").mother(mother).build(); Children children02 = Children.builder().name("張四").mother(mother).build(); childrenList.add(children01); childrenList.add(children02); mother.setChildrenList(childrenList); Mother mother1 = motherRepository.save(mother); System.out.println(mother1.getId()); } /** * 級聯刪除。 * 刪除 Mother 的同時,也刪除 Children 表。 */ @Test public void cascadeDelete() { Mother mother = Mother.builder().id(2).build(); List<Children> childrenList = new ArrayList<>(1); Children children01 = Children.builder().id(3).build(); Children children02 = Children.builder().id(4).build(); childrenList.add(children01); childrenList.add(children02); mother.setChildrenList(childrenList); motherRepository.delete(mother); } ``` ```java /************************** Children -> Mother **************************/ /** * 級聯保存/更新。 * 保存/更新 Children 的同時,也保存/更新 Mother 表。 */ @Test public void cascadeSave() { Mother mother = Mother.builder().name("王母").build(); List<Children> childrenList = new ArrayList<>(1); Children children = Children.builder().name("王三").mother(mother).build(); childrenList.add(children); mother.setChildrenList(childrenList); Children children1 = childrenRepository.save(children); System.out.println(children1.getId()); } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看