我有这个模型复杂的数据:
@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<AbstractRef> 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 {
}
数据库示例:
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
我想通过使用 B、C 和 D 的集合值而不是技术 id 来获得 A(1, X)
List<String> values = Arrays.asList(new String[]{"H","I","P","O","Z","F"});
A aWithFunctinnalId = service.getA(values);
就我而言,值的集合(“H”、“I”、“P”、“O”、“Z”、“F”)是我的函数 ID。
我怎么能这样做?
谢谢您的帮助!