javax.el.PropertyNotFoundException:找不到类型为org.hibernate.collection.internal.PersistentSet的属性 [英] javax.el.PropertyNotFoundException: Property not found on type org.hibernate.collection.internal.PersistentSet

查看:220
本文介绍了javax.el.PropertyNotFoundException:找不到类型为org.hibernate.collection.internal.PersistentSet的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从关联ManyToMany中恢复数据,但我不能,这是我的代码。



实体产品:

  @Entity 
public class实现Serializable {

@Id
@Column(name =Produit_ID)
@GeneratedValue
私人长ID;
私人字符串dq;
私人字符串icForme;
private String ich;
私人字符串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

实体终端:

  @Entity 
public class Terminal实现Serializable {

@Id
@GeneratedValue
@Column(name =Terminal_ID)
私人长ID;
private String crimpkontakt;
私人字符串设备;
private String geometrie;
私人字符串dcbt;
private String icb;
private String ak;

@ManyToMany(mappedBy =terminals)
private Set<产品> produit = new HashSet< Produit>();

// getter setter

Class:ModuleJPADao

  public List<产品> parProduit(String cat){
cat =%+ cat +%;
查询查询= getEntityManger()。createQuery(from+ getPersistentClass()。getSimpleName()
+u其中u.produit LIKE:cat)。setParameter(cat,cat);
列表<产品> module =(List)query.getResultList();
返回模块;

$ b $ / code>

Class:ModuleService

  public List<产品> tousModuleProduit(String produit){

if(produit!= null){
return moduleDao.parProduit(produit);
}
else {
return null;


$ / code $ / pre

main-flow.xml

 < view-state id =accueilview =accueil.xhtml> 
< on-render>
< evaluate expression =moduleService.tousModuleProduit(module.getProduit())
result =viewScope.recherche/>

< / on-render>
< / view-state>

file.xhtml

 < p:accordionPanel value =#{recherche}var =car> 


< h:panelGrid columns =4cellspacing =20>

< p:outputLabel value =ICHT:/>
< p:inputText value =#{car.icht}/>

< p:outputLabel value =terminals:/>
< h:form>
< h:dataTable value =#{car.terminals}var =der>
< p:栏>
< h:outputText value =#{der.geometrie}/>
< / p:栏>

< / h:dataTable>
< / h:表格>


< / h:panelGrid>
....

我无法获得geometrie的值;我得到了这个错误:

 javax.el.PropertyNotFoundException:/WEB-INF/flows/main/accueil.xhtml @ 84,53 value =#{ der.geometrie}:未在类型org.hibernate.collection.internal.PersistentSet中找到属性'geometrie'


解决方案


 < h:dataTable value =#{car.terminals}var =der> 
< p:栏>
< h:outputText value =#{der.geometrie}/>

javax.el.PropertyNotFoundException:未在类型org.hibernate.collection.internal上找到属性'geometrie' .PersistentSet

因此,#{car.terminals} 是一个组< E - 代替; < h:dataTable> < p:dataTable> < ui :repeat> 组件不支持遍历 Set< E> 。然后,#{der} 将基本上代表 Set < / code>本身。迭代 Set< E> 的内置支持将在未来的JSF 2.3版本中出现。

如果它不是一个用 List< E>替换 Set< E> ; ,然后从下面获取一个数组:

 < h:dataTable value =#{car.terminals.toArray()}var =terminal> 


I try to recuperate data from association ManyToMany but i can't, this is my code.

Entity Produit :

@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

Entity Terminal :

@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

Class : 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;

}

Class : ModuleService

public List<Produit> tousModuleProduit(String produit) {

    if(produit!= null){
        return moduleDao.parProduit(produit);
    }
    else{
        return null;
    }
}

main-flow.xml

<view-state id="accueil" view="accueil.xhtml">
    <on-render>
        <evaluate expression="moduleService.tousModuleProduit(module.getProduit())"
            result="viewScope.recherche" />

    </on-render>
</view-state>

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>
        ....

i can't get the value of geometrie; i got this erreur:

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

解决方案

<h:dataTable value="#{car.terminals}" var="der">
    <p:column>
        <h:outputText value="#{der.geometrie}" />

javax.el.PropertyNotFoundException: Property 'geometrie' not found on type org.hibernate.collection.internal.PersistentSet

Thus, the #{car.terminals} is a Set<E>. The <h:dataTable>, <p:dataTable> and <ui:repeat> components doesn't support iterating over a Set<E>. The #{der} will then basically represent the Set<E> itself. The builtin support for iterating over Set<E> will come in future JSF 2.3 version.

If it's not an option to replace Set<E> by a List<E>, then just get an array out of it as below:

<h:dataTable value="#{car.terminals.toArray()}" var="terminal">

这篇关于javax.el.PropertyNotFoundException:找不到类型为org.hibernate.collection.internal.PersistentSet的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆