java.lang.TypeNotPresentException:键入bookingSessionBean.Plot不存在

时间:2014-12-06 09:12:51

标签: jsf managed-bean

我想显示数据库中的图表列表。我在包viewBean中创建了plot.java,在包viewBean中创建了viewPlot.java,但它不起作用。

index.xhtml代码:

<h:body>
    <h1><h:outputText value="Selected Plot" /></h1>
    <h:form>
        <f:view>
            <h:dataTable value="#{viewPlot.plots}" var="item">
                <h:column>
                    <h:outputText value="#{item.plotno}" />
                </h:column>
            </h:dataTable>
        </f:view>
    </h:form>
</h:body>

viewPlot.java代码

@ManagedBean
@Named(value = "viewPlot")
@SessionScoped
public class viewPlot implements Serializable {
    @PersistenceContext(unitName = "2day4uPU")
    private EntityManager em;

    public viewPlot() {
    }

    public List<Plot> getPlots()
    {
        return em.createNamedQuery("Plot.findAll").getResultList();

    }

}

Plot.java代码

@Entity
@Table(name = "PLOT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Plot.findAll", query = "SELECT p FROM Plot p"),
    @NamedQuery(name = "Plot.findByPlotno", query = "SELECT p FROM Plot p WHERE p.plotno = :plotno"),
    @NamedQuery(name = "Plot.findByStartdate", query = "SELECT p FROM Plot p WHERE p.startdate = :startdate"),
    @NamedQuery(name = "Plot.findByEnddate", query = "SELECT p FROM Plot p WHERE p.enddate = :enddate"),
    @NamedQuery(name = "Plot.findByAvailableplot", query = "SELECT p FROM Plot p WHERE p.availableplot = :availableplot")})
public class Plot implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PLOTNO")
    private Integer plotno;
    @Basic(optional = false)
    @NotNull
    @Column(name = "STARTDATE")
    @Temporal(TemporalType.DATE)
    private Date startdate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ENDDATE")
    @Temporal(TemporalType.DATE)
    private Date enddate;
    @Column(name = "AVAILABLEPLOT")
    private Integer availableplot;
    @JoinColumn(name = "ACCOMNO", referencedColumnName = "ACCOMNO")
    @ManyToOne(optional = false)
    private Accomodation accomno;
    @JoinColumn(name = "SITENO", referencedColumnName = "SITENO")
    @ManyToOne(optional = false)
    private Site siteno;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "plotno")
    private Collection<Booking> bookingCollection;

    public Plot() {
    }

    public Plot(Integer plotno) {
        this.plotno = plotno;
    }

public Plot(Integer plotno, Date startdate, Date enddate) {
    this.plotno = plotno;
    this.startdate = startdate;
    this.enddate = enddate;
}

public Integer getPlotno() {
    return plotno;
}

public void setPlotno(Integer plotno) {
    this.plotno = plotno;
}

public Date getStartdate() {
    return startdate;
}

public void setStartdate(Date startdate) {
    this.startdate = startdate;
}

public Date getEnddate() {
    return enddate;
}

public void setEnddate(Date enddate) {
    this.enddate = enddate;
}

public Integer getAvailableplot() {
    return availableplot;
}

public void setAvailableplot(Integer availableplot) {
    this.availableplot = availableplot;
}

public Accomodation getAccomno() {
    return accomno;
}

public void setAccomno(Accomodation accomno) {
    this.accomno = accomno;
}

public Site getSiteno() {
    return siteno;
}

public void setSiteno(Site siteno) {
    this.siteno = siteno;
}

@XmlTransient
public Collection<Booking> getBookingCollection() {
    return bookingCollection;
}

public void setBookingCollection(Collection<Booking> bookingCollection) {
    this.bookingCollection = bookingCollection;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (plotno != null ? plotno.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Plot)) {
        return false;
    }
    Plot other = (Plot) object;
    if ((this.plotno == null && other.plotno != null) || (this.plotno != null && !this.plotno.equals(other.plotno))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "bookingSessionBean.Plot[ plotno=" + plotno + " ]";
}

}

[我该如何解决这个错误? ]

0 个答案:

没有答案