访问从数据库视图创建的实体时的JPA PropertyNotFoundException

时间:2014-05-07 22:33:12

标签: java jpa

我从数据库视图创建了实体。我的实体:

@Entity
@Table(name = "viewrpdh")
@XmlRootElement
@NamedQueries({bla bla})
public class Viewrpdh implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "tanggal")
    private Date tanggal;
    @Basic(optional = false)
    @NotNull
    @Column(name = "rPDM_bulan")
    private int rPDMbulan;
    @Basic(optional = false)
    @NotNull
    @Column(name = "rPDM_minggu_ke")
    private int rPDMmingguke;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "rPDM_satker_kode_departemen")
    private String rPDMsatkerkodedepartemen;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "rPDM_satker_kode_unit_organisasi")
    private String rPDMsatkerkodeunitorganisasi;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "rPDM_satker_kode_satker")
    private String rPDMsatkerkodesatker;
    etc;

我的servlet中的代码:

 List<Viewrpdh> daftarHarian = viewrpdhFacade.aMethodUsingNamedQuery(some parameter);
 request.setAttribute("daftarHarian", daftarHarian);

我的JSP中的代码:

<c:forEach var="column" items="${daftarHarian}">
    <tr>
        <td><c:out value="${column.rPDMsatkerkodeunitorganisasi}"/></td>
        <td><c:out value="${column.rPDMsatkerkodesatker}"/></td>
        <td><c:out value="${column.nilaiKotor51}"/></td>
        etc
    </tr>
</c:forEach>

当我运行程序时,我遇到了错误:

org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'entity.Viewrpdh' does not have the property 'rPDMsatkerkodeunitorganisasi'.

当我尝试访问名为rPDM的列时会发生这种情况,但如果我尝试访问其他列,则不会发生这种情况,例如:tanggal。仅供参考,rpdh,rpdm和satker是我的数据库中的表,这些实体是由netbean生成的。请帮助我,对不起我糟糕的英语。

1 个答案:

答案 0 :(得分:0)

删除

@Id
@Basic

来自各个领域。
仅将@Id保留在表格中的ID字段中 检查你是否有安装者和吸气剂。