EJB和JPA类格式错误

时间:2011-08-10 17:33:52

标签: jpa ejb

hello iam尝试在我的Web应用程序中向我的数据库添加一个对象,我得到以下异常java.lang.ClassFormatError:类文件Entity / Rpxfornecedor_中的重复字段名称和签名。这是实体Rpxfornecedor的代码:

@Entity
@Table(name = "rpxfornecedor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Rpxfornecedor.findAll", query = "SELECT r FROM Rpxfornecedor r"),
    @NamedQuery(name = "Rpxfornecedor.findByFid", query = "SELECT r FROM Rpxfornecedor r WHERE r.fid = :fid"),
    @NamedQuery(name = "Rpxfornecedor.findByFNome", query = "SELECT r FROM Rpxfornecedor r WHERE r.fNome = :fNome"),
    @NamedQuery(name = "Rpxfornecedor.findByFDescri\u00e7\u00e3o", query = "SELECT r FROM Rpxfornecedor r WHERE r.fDescri\u00e7\u00e3o = :fDescri\u00e7\u00e3o"),
    @NamedQuery(name = "Rpxfornecedor.findByFNTel", query = "SELECT r FROM Rpxfornecedor r WHERE r.fNTel = :fNTel"),
    @NamedQuery(name = "Rpxfornecedor.findByFNCel", query = "SELECT r FROM Rpxfornecedor r WHERE r.fNCel = :fNCel"),
    @NamedQuery(name = "Rpxfornecedor.findByFEndere\u00e7o", query = "SELECT r FROM Rpxfornecedor r WHERE r.fEndere\u00e7o = :fEndere\u00e7o"),
    @NamedQuery(name = "Rpxfornecedor.findByFEmail", query = "SELECT r FROM Rpxfornecedor r WHERE r.fEmail = :fEmail"),
    @NamedQuery(name = "Rpxfornecedor.findByFFax", query = "SELECT r FROM Rpxfornecedor r WHERE r.fFax = :fFax"),
    @NamedQuery(name = "Rpxfornecedor.findByFActivo", query = "SELECT r FROM Rpxfornecedor r WHERE r.fActivo = :fActivo"),
    @NamedQuery(name = "Rpxfornecedor.findByFDataAct", query = "SELECT r FROM Rpxfornecedor r WHERE r.fDataAct = :fDataAct"),
    @NamedQuery(name = "Rpxfornecedor.findByFDataNAct", query = "SELECT r FROM Rpxfornecedor r WHERE r.fDataNAct = :fDataNAct")})
public class Rpxfornecedor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 80)
    @Column(name = "FID")
    private String fid;
    @Size(max = 80)
    @Column(name = "FNome")
    private String fNome;
    @Size(max = 1000)
    @Column(name = "FDescri\u00e7\u00e3o")
    private String fDescrição;
    @Size(max = 45)
    @Column(name = "FNTel")
    private String fNTel;
    @Size(max = 45)
    @Column(name = "FNCel")
    private String fNCel;
    @Size(max = 200)
    @Column(name = "FEndere\u00e7o")
    private String fEndereço;
    @Size(max = 100)
    @Column(name = "FEmail")
    private String fEmail;
    @Size(max = 45)
    @Column(name = "FFax")
    private String fFax;
    @Column(name = "FActivo")
    private Character fActivo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "FDataAct")
    private String fDataAct;
    @Size(max = 200)
    @Column(name = "FDataNAct")
    private String fDataNAct;

    public Rpxfornecedor() {
    }

    public Rpxfornecedor(String fid) {
        this.fid = fid;
    }

    public Rpxfornecedor(String fid, String fDataAct) {
        this.fid = fid;
        this.fDataAct = fDataAct;
    }

    public String getFid() {
        return fid;
    }

    public void setFid(String fid) {
        this.fid = fid;
    }

    public String getFNome() {
        return fNome;
    }

    public void setFNome(String fNome) {
        this.fNome = fNome;
    }

    public String getFDescrição() {
        return fDescrição;
    }

    public void setFDescrição(String fDescrição) {
        this.fDescrição = fDescrição;
    }

    public String getFNTel() {
        return fNTel;
    }

    public void setFNTel(String fNTel) {
        this.fNTel = fNTel;
    }

    public String getFNCel() {
        return fNCel;
    }

    public void setFNCel(String fNCel) {
        this.fNCel = fNCel;
    }

    public String getFEndereço() {
        return fEndereço;
    }

    public void setFEndereço(String fEndereço) {
        this.fEndereço = fEndereço;
    }

    public String getFEmail() {
        return fEmail;
    }

    public void setFEmail(String fEmail) {
        this.fEmail = fEmail;
    }

    public String getFFax() {
        return fFax;
    }

    public void setFFax(String fFax) {
        this.fFax = fFax;
    }

    public Character getFActivo() {
        return fActivo;
    }

    public void setFActivo(Character fActivo) {
        this.fActivo = fActivo;
    }

    public String getFDataAct() {
        return fDataAct;
    }

    public void setFDataAct(String fDataAct) {
        this.fDataAct = fDataAct;
    }

    public String getFDataNAct() {
        return fDataNAct;
    }

    public void setFDataNAct(String fDataNAct) {
        this.fDataNAct = fDataNAct;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (fid != null ? fid.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 Rpxfornecedor)) {
            return false;
        }
        Rpxfornecedor other = (Rpxfornecedor) object;
        if ((this.fid == null && other.fid != null) || (this.fid != null && !this.fid.equals(other.fid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Rpxfornecedor[ fid=" + fid + " ]";
    }

}

以下代码中出现错误:

public Rpxfornecedor addfornecedor(String Id, String nome, String endereço, String email, String cell, String tel, String fax, String des, String dnow){
     Rpxfornecedor Forn = new Rpxfornecedor();


     //em.flush();
     Forn.setFid(Id);
     Forn.setFNome(nome);
     Forn.setFEndereço(endereço);
     Forn.setFEmail(email);
     Forn.setFNCel(cell);
     Forn.setFNTel(tel);  
     Forn.setFFax(fax); 
     Forn.setFDescrição(des); 
     Forn.setFActivo('Y');
     Forn.setFDataAct(dnow);
     Forn.setFDataNAct("fbedfdf");     

     if(Forn != null){
      em.persist(Forn);  
      //em.persist(Forn);      
     }


     return Forn;
    }

所以,任何建议都将不胜感激。

我使用的JPA实现是EclipseLink 2.0。我尝试更改jpa,但我仍然遇到netbeans 7.0.1附带的每一个问题。

1 个答案:

答案 0 :(得分:0)

我终于想通了,我改变了数据库中的字段名称和实体来修复它。例如:

@Column(name = "FDescri\u00e7\u00e3o")

应该是

@Column(name = "FDescricao")