<code id="qf3hh"></code>
  • <menuitem id="qf3hh"></menuitem>
  • <strike id="qf3hh"><label id="qf3hh"></label></strike>

  • ?
      開(kāi)發(fā)技術(shù) / Technology

      JPA的查詢語(yǔ)言—JPQL的關(guān)聯(lián)查詢

      日期:2015年3月25日  作者:zhjw  來(lái)源:互聯(lián)網(wǎng)    點(diǎn)擊:970

       

      從一關(guān)聯(lián)到多的查詢和從多關(guān)聯(lián)到一的查詢來(lái)簡(jiǎn)單說(shuō)說(shuō)關(guān)聯(lián)查詢。

        實(shí)體Team:球隊(duì)。

        實(shí)體Player:球員。

        球隊(duì)和球員是一對(duì)多的關(guān)系。

        Team.java:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      package com.cndatacom.jpa.entity;
       
      import java.util.HashSet;
      import java.util.Set;
       
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;
       
       
      /**
       * 球隊(duì)
       * @author Luxh
       */
      @Entity
      @Table(name="team")
      public class Team{
       
          @Id
          @GeneratedValue
          private Long id;
           
          /**球隊(duì)名稱*/
          @Column(name="name",length=32)
          private String name;
           
          /**擁有的球員*/
          @OneToMany(mappedBy="team",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
          private Set<Player> players = new HashSet<Player>();
       

      国产一级婬片AAA毛,无码中文精品视视在线观看,欧美日韩a人成v在线动漫,五月丁香青草久久
      <code id="qf3hh"></code>
    • <menuitem id="qf3hh"></menuitem>
    • <strike id="qf3hh"><label id="qf3hh"></label></strike>