I ran into a weird issue with PrimeFaces 2.1RC1. I use PrimeFaces with JSF 2.0 in Netbeans 6.8 with Java 1.6.0_17 and a Glassfish v3.0 server. I have some Entity beans which I want to display in a dataTable which contains associations as Sets which I want to have displayed
My object (excerpt):
Code: Select all
//Many imports...
@Entity
@Table(name="fourfivefour_chunks")
@AttributeOverrides(
{
@AttributeOverride(name="ID",column=@Column(name="id"))
}
)
@SequenceGenerator(name = "seq", sequenceName = "fourfivefour_chunks_id_seq")
public class fourfivefourChunk extends biotype {
//many stuff omitted...
private Set<experimentChunkLnk> experiments = null;
//THIS FUNCTION MAKES TROUBLE!
@OneToMany(mappedBy="chunk")
@Cascade({ org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
org.hibernate.annotations.CascadeType.DELETE })
public Set<experimentChunkLnk> getExperiments() {
if (this.experiments==null){
this.experiments = new HashSet<experimentChunkLnk>();
this.experiments.add(new experimentChunkLnk());
}
return experiments;
}
public void setExperiments(Set<experimentChunkLnk> experiments) {
this.experiments = experiments;
}
//A NOT PERSISTED FUNCTION WHICH ALSO MAKES TROUBLE!
@Transient
public Set<biorole> getAssignedRoles(){
Set<biorole> bfr = new HashSet<biorole>();
if (this.getRun()!= null && this.getMid()!= null){
for (Iterator<midRoleLnk> i = this.getRun().getMidRoles().iterator();i.hasNext();){
midRoleLnk mrl = i.next();
if (mrl.getMid().equals(this.getMid())){
bfr.add(mrl.getRole());
}
}
}
return bfr;
}
//many stuff omitted...
}
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:l="http://java.sun.com/jsf/composite/components">
<body>
<h:outputScript name="jsf.js" library="javax.faces" target="head"/>
<ui:composition template="./../resources/templates/loggedInTemplate.xhtml">
<ui:define name="page_title">fourfivefourRuns</ui:define>
<ui:define name="content">
<f:view>
<!-- many stuff omitted! -->
<p:panel>
<h3><h:outputText value="chunks in current run"/></h3>
<p:dataTable id="currentChunksTbl" value="#{fourfivefourGlobals.currentRunChunks}" var="item"
paginator="true" rows="10" dynamic="false">
<p:column>
<f:facet name="header">
<h:outputText value="experiments"/>
</f:facet>
<h:outputText value="#{item.experiments}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="AssignedRoles"/>
</f:facet>
<h:outputText value="#{item.assignedRoles}"/>
</p:column>
</p:dataTable>
<h:commandButton value="create analysis run" action="createAnalysisRun"/>
<h:commandButton value="update sequence count" action="not implemented"/>
<h:commandButton value="refresh current run" action="not implemented"/>
</p:panel>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</body>
</html>
The problem does NOT occur if the table does not contain any Collection properties.
The problem does NOT occur if all returned collections are empty.
The problem is most likely unrelated to any Hibernate lazy loading or persistence issue, since replacing the property .getExperiments() with a mock:
Code: Select all
public Set<experimentChunkLnk> getExperiments(){
Set<experimentChunkLnk> bfr = new HashSet();
bfr.add(new experimentChunkLnk());
return bfr;
Any hints or pointers into the right direction?
Thank you in advance, Regards
Volker