다음은 인터페이스 위에 구현하는 클래스 정의Hibernate 5에서 제네릭 형식 매개 변수를 사용하는 방법은 무엇입니까?
인터페이스
public interface myInterface{
void myMethod1();
}
MyClass1 클래스에게 있습니다
@Entity
public class MyClass1 implements MyInterface{
@Id
private int id;
private String field1;
private String field2;
// Getter and setter
}
MyClass2의 클래스
@Entity
public class MyClass2 implements MyInterface{
@Id
private int id;
private String field3;
private String field4;
// Getter and setter
}
마지막으로 type 매개 변수가있는 목록이있는 엔터티 클래스.
@Entity
public class MyClass{
@Id
priviate int id;
private String field5;
private String field6;
private List<? extends MyInterface> mylist;
//getter and setter
}
내가보고있는 생성 된 클래스는 다음과 같습니다.
MyClass의 표
-------------------------
id | field5 | field6
-------------------------
1 | abc | def
2 | abc | def
3 | abc | def
MyClass1 표
-------------------------
id | field1 | field2 | myclass_fk
-------------------------
1 | abc | def | 2
2 | abc | def | 2
3 | abc | def | 1
MyClass2의 표
-------------------------
id | field3 | field4 | myclass_fk
-------------------------
1 | abc | def | 3
2 | abc | def | 1
3 | abc | def | 1
I 폴리스 시도 se @OneToMany
은 targetType이 MyInterface 인 목록에 있지만 엔티티 클래스가 아니라 오류로 인해 실패했습니다. 어떤 도움이라도 대단히 감사합니다.
EDIT가
것이 바람직 그래프 또는 몽고 (문서)를 기반으로하여, 하이버 네이트 OGM 달성 될 수있다.