【发布时间】:2011-03-11 01:49:59
【问题描述】:
我在 primefaces dataGrid 中有一个 primefaces dataList,但在映射到嵌套 dataList 集合 (java.util.Set) 的属性时遇到问题。当我引用嵌套集(dream.tag)上的任何属性时,我得到异常:
javax.servlet.ServletException: /registered/modify.xhtml @42,48 value="#{tag.id}": 在类型 org.hibernate.collection.PersistentSet 上找不到属性 'id'。
那个属性是存在的,但是dream.tag 属性被映射到一个私有的Set 标签。是否可以将 dataList 组件与 Set.我在下面复制了我的数据模型的大纲。感谢您的帮助!
<p:dataGrid var="dream" value="#{dreamModifyBean.dreams}" columns="5" rows="10" paginator="true" effect="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,15,20" paginatorPosition="bottom">
<p:column>
<h:panelGrid columns="1" style="width:100%">
<h:outputText value="#{dream.order}. #{dream.title}"/><br/>
<p:graphicImage value="#{dream.imageThumb}" width="125" height="100"/><br/>
<h:outputText value="#{dream.notes}"/><br/>
<p:dataList value="#{dream.tag}" var="tag">
<h:outputText value="#{tag.id}"/>
</p:dataList>
<h:outputText value="#{bundle['dreamModify.cost.TEXT']} #{dream.cost}"/><br/>
</h:panelGrid>
</p:column>
</p:dataGrid>
梦想 (dreamModifyBean.dreams) - 家长:
public class Dream implements Serializable{
@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@JoinColumn(name="DREAM_ID")
private Set<Tag> tag;
public Set<Tag> getTag() {
return tag;
}
public void setTag(Set<Tag> tag) {
this.tag = tag;
}
}
标签 (dream.tag) - 孩子
public class Tag {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Basic(optional=false)
@Column(name="ID")
private Long id;
@Basic(optional=false)
@Column(name="DESCRIPTION")
private String description;
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="DREAM_ID")
private Dream dream;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Dream getDream() {
return dream;
}
public void setDream(Dream dream) {
this.dream = dream;
}
}
【问题讨论】:
标签: java hibernate jsf primefaces