我想,从一个键,访问上面的实体键
这种关系是:
规则包含术语规则。每个termrule包含一个规则和一个变量配置。
只有variableconfiguration包含变量。
我想,从termrule,捕获变量。
我试着这样: termRule.getVariableConfiguration().getVariable()
接收空。
有可能得到一个项的变量吗?
public class Rule extends PersistentObject {
private static final long serialVersionUID = 7852189080136935020L;
@Column (name ="NAME", nullable = false)
private String namerule;
@OneToMany(mappedBy = "rule", fetch = FetchType.LAZY)
private List<TermRule> termRule;
}
//getters and setters
public class TermRule extends PersistentObject implements Comparable<TermRule> {
private static final long serialVersionUID = 336244667983772321L;
@ManyToOne
@JoinColumn(name = "ID_RULE", referencedColumnName = "ID", nullable = false)
private Rule rule;
@OneToOne
@JoinColumn (name ="ID_VAR_CONF", referencedColumnName = "ID", nullable = true)
private VariableConfiguration variableConfiguration;
}
public abstract class VariableConfiguration extends PersistentObject {
private static final long serialVersionUID = -4967631633375881594L;
@ManyToOne
@JoinColumn(name = "ID_VARIAVEL", referencedColumnName = "ID", nullable = false)
private Variable variable;
@OneToOne (mappedBy= "variableConfiguration", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
private TermRule termRule;
}
@DiscriminatorValue("Triangle")
public class Triangle extends VariableConfiguration {
}
public class Variable extends PersistentObject {
private static final long serialVersionUID = -1172539974105845401L;
@Column (name = "NOME", nullable = false)
private String name;
@OneToMany (mappedBy= "variable", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
private List<VariableConfiguration> variableConfiguration;
}
暂无答案!
目前还没有任何答案,快来回答吧!