title: JPA : mapping complexe data
body: <p>I have this model complex data :</p>
  
  <pre><code>@Entity
  public class A {
      @id
      public Long id;
  
      @Column
      public String code;
  
      @OneToMany
      @JoinTable(name = "A_REF",
      joinColumns = @JoinColumn(name = "ID_A"),
      inverseJoinColumns = @JoinColumn(name = "ID_REF"))
      public Set&lt;AbstractRef&gt; refs;
  
  }
  
  
  @Entity
  @Table("T_REF")
  @DiscriminatorColumn(name="type")
  public abstract class AbstractRef {
      @id
      public Long id;
  
      @Column
      public String value;
  }
  
  
  
  @Entity
  @DiscriminatorValue(value="B")
  public class B extends AbstractRef {
  }
  
  
  
  @Entity
  @DiscriminatorValue(value="C")
  public class C extends AbstractRef{
  }
  
  @Entity
  @DiscriminatorValue(value="D")
  public class D extends AbstractRef {
  }
  </code></pre>
  
  <p>Example of data base :</p>
  
  <pre><code>T_A
  ID | NAME
  1  |  X
  2  |  Y
  
  T_REF
  ID | VALUE | TYPE | ID_A
  1  |  H    |   B  |  1
  2  |  I    |   B  |  1
  3  |  H    |   B  |  2
  4  |  P    |   C  |  1
  5  |  O    |   C  |  1
  6  |  O    |   C  |  2
  7  |  Z    |   D  |  1
  8  |  F    |   D  |  1
  9  |  M    |   D  |  2
  </code></pre>
  
  <p>I want to get A(1, X) by using an collection values of B, C and D, not by technical id</p>
  
  <pre><code>List&lt;String&gt; values = Arrays.asList(new String[]{"H","I","P","O","Z","F"});
  A aWithFunctinnalId = service.getA(values);
  </code></pre>
  
  <p>for my case, collection of values ("H","I","P","O","Z","F") is my functionnal id.</p>
  
  <p>how i can do that ? </p>
  
  <p>Thank you for your help!</p>