我开始在JPA 2.1中使用新的实体图形功能来指定必须加载的Lazy集合.考虑以下课程:
@Entity
@NamedQueries({
@NamedQuery(name="findWithFilterAttr","select a from A a where a.filterAttribute like :filter")
})
@NamedEntityGraphs({
@NamedEntityGraph(name = "graph.childs", attributeNodes = @NamedAttributeNode("childs"))})
public class A{
@Id
private long id;
@OneToMany(mappedBy="parent")
private List<B> childs;
private String filterAttribute;
}
@Entity
public class B{
@Id
private long id;
@ManyToOne
private A parent;
}
Run Code Online (Sandbox Code Playgroud)
当我执行命名查询以获取具有实体图形提示的A实体列表时,我得到一个带有重复A实体的集合.如何只加载A实体一次.
我正在使用:
我正在使用primefaces 3.4.1而我正在尝试在子表中使用带有ajax调用的SelectOneRadio, 但它不起作用,不调用ajax监听器
<p:dataTable id="competenciesTable" var="competency" value="#{evaluationControl.currentEvaluation.evaluatedCompetencies}">
<f:facet name="header">
<h:outputText value="#{gchmsg['global.competencies']}" />
</f:facet>
<p:subTable id="descriptorsTable" var="descriptor" value="#{competency.evaluationDescriptors}">
<f:facet name="header">
<h:outputText class="strong" value="#{competency.competency.name}" />
</f:facet>
<p:column>#{descriptor.descriptor.description}</p:column>
<p:column>
<p:selectOneRadio required="true" styleClass="calification_scale" id="descriptorCalification" value="#{descriptor.calification}" converter="calification">
<f:selectItems value="#{competency.competency.calificationSchema.scales}" var="scale" itemLabel="#{scale.qualitativeValue}" itemDescription="#{scale.description}" itemValue="#{scale}" />
<p:ajax process="@this" listener="#{evaluationControl.handleRadioChange}" update=":evaluationForm:finalResultText, descriptorCalificationMsg" />
</p:selectOneRadio>
<p:message id="descriptorCalificationMsg" for="descriptorCalification" display="icon" />
</p:column>
</p:subTable>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
evaluateControl是一个SessionBean,方法是
public void handleRadioChange() {
log.debug("Listener called");
}
Run Code Online (Sandbox Code Playgroud)
感谢帮助.