我有 2 个以上的类,它们大约有 7 个相同的字段,在 java 部分中将如下所示:
public abstract class IBase {
private String commonField1;
private String commonField2;
private String commonField3;
private EMyType type; // type of the object: MY_TYPE_1 or MY_TYPE_2
// ...
// + constructor and getters/setters
}
public class BaseImpl1 extends IBase {
private int base1specific1;
private int base1specific2;
// ...
// + constructor and getters/setters
}
public class BaseImpl2 extends IBase {
private int base2specific;
private String base2specific2;
// ...
// + constructor and getters/setters
}
我有两个问题:
- 在数据库中反映这两个对象的最佳方法是什么?
- 我应该如何通过 Hibernate 检索它们?