use*_*890 5 jsf many-to-many hibernate propertynotfoundexception
我试图从关联ManyToMany恢复数据,但我不能,这是我的代码.
实体产品:
@Entity
public class Produit implements Serializable {
@Id
@Column(name="Produit_ID")
@GeneratedValue
private Long id;
private String dq;
private String icForme;
private String ich;
private String icht;
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(name="produit_terminal",
joinColumns={@JoinColumn(name="Produit_ID")},
inverseJoinColumns={@JoinColumn(name="Terminal_ID")})
private Set<Terminal> terminals = new HashSet<Terminal>();
//getter setter
Run Code Online (Sandbox Code Playgroud)
实体终端:
@Entity
public class Terminal implements Serializable{
@Id
@GeneratedValue
@Column(name="Terminal_ID")
private Long id;
private String crimpkontakt;
private String equipment;
private String geometrie;
private String dcbt;
private String icb;
private String ak;
@ManyToMany(mappedBy="terminals")
private Set<Produit> produit = new HashSet<Produit>();
//getter setter
Run Code Online (Sandbox Code Playgroud)
课程:ModuleJPADao
public List<Produit> parProduit(String cat){
cat = "%" + cat + "%";
Query query = getEntityManger().createQuery( "from "+ getPersistentClass().getSimpleName()
+" u where u.produit LIKE :cat").setParameter( "cat", cat );
List<Produit> module = (List) query.getResultList();
return module;
}
Run Code Online (Sandbox Code Playgroud)
类:ModuleService
public List<Produit> tousModuleProduit(String produit) {
if(produit!= null){
return moduleDao.parProduit(produit);
}
else{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
主flow.xml
<view-state id="accueil" view="accueil.xhtml">
<on-render>
<evaluate expression="moduleService.tousModuleProduit(module.getProduit())"
result="viewScope.recherche" />
</on-render>
</view-state>
Run Code Online (Sandbox Code Playgroud)
file.xhtml
<p:accordionPanel value="#{recherche}" var="car">
<p:tab title="IcForme : #{car.icForme}">
<h:panelGrid columns="4" cellspacing="20">
<p:outputLabel value="ICHT: " />
<p:inputText value="#{car.icht}" />
<p:outputLabel value="terminals : " />
<h:form>
<h:dataTable value="#{car.terminals}" var="der" >
<p:column>
<h:outputText value="#{der.geometrie}" />
</p:column>
</h:dataTable>
</h:form>
</h:panelGrid>
....
Run Code Online (Sandbox Code Playgroud)
我无法获得几何学的价值; 我得到了这个错误:
javax.el.PropertyNotFoundException: /WEB-INF/flows/main/accueil.xhtml @84,53 value="#{der.geometrie}": Property 'geometrie' not found on type org.hibernate.collection.internal.PersistentSet
Bal*_*usC 16
Run Code Online (Sandbox Code Playgroud)<h:dataTable value="#{car.terminals}" var="der"> <p:column> <h:outputText value="#{der.geometrie}" />javax.el.PropertyNotFoundException:在类型org.hibernate.collection.internal.PersistentSet上找不到属性'geometrie'
因此,#{car.terminals}是一个Set<E>.的<h:dataTable>,<p:dataTable>而<ui:repeat>组件不支持通过迭代Set<E>.然后,#{der}遗嘱基本上代表了Set<E>自己.内置的迭代支持Set<E>将在未来的JSF 2.3版本中出现.
如果它不是Set<E>由a 替换的选项List<E>,那么只需从中获取一个数组,如下所示:
<h:dataTable value="#{car.terminals.toArray()}" var="terminal">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4073 次 |
| 最近记录: |