Jpa 我需要帮助来显示表的id,但我';我有它的内存地址
我有两个类,Orgulatour和salle由Orgulatour中的ManyToOne映射,我想在Orgulatour表中显示salles的id,但我得到的是salle的内存地址Jpa 我需要帮助来显示表的id,但我';我有它的内存地址,jpa,jsf,el,Jpa,Jsf,El,我有两个类,Orgulatour和salle由Orgulatour中的ManyToOne映射,我想在Orgulatour表中显示salles的id,但我得到的是salle的内存地址 This is the mapping in the ordinateur class @ManyToOne @JoinColumn(name="code_salle") private Salle salle; p
This is the mapping in the ordinateur class
@ManyToOne
@JoinColumn(name="code_salle")
private Salle salle;
public Salle getSalle() {
return salle;
}
and here where i want to display it
<h:column>
<f:facet name="header">Code de la salle</f:facet>
<h:outputText value="#{ordinateur.salle}"></h:outputText>
</h:column>
这是纵坐标类中的映射
@许多酮
@JoinColumn(name=“code\u salle”)
二等兵萨利;
公共服务{
回击;
}
在这里我想展示它
德拉萨尔代码
您的EL表达式引用的是ordinatiur
中的salle
属性,因此,您将得到salle
对象。EL将调用对象上的toString()
,这就是您看到的输出。您需要输出的是#{ordinatiur.salle.id}
顺便说一下,您看到的不是内存地址,而是类名和对象的哈希代码。请参阅默认的toString()
实现:
公共字符串toString(){
返回getClass().getName()+“@”+Integer.toHexString(hashCode());
}