错误:org.hibernate.AnnotationException:mappedBy引用未知的目标实体属性

时间:2015-03-30 15:42:33

标签: java hibernate jpa

我是JPA和Hibernate的新手,我发现了映射这两个表的问题:

FORUM.JAVA:

    package edu.app.persistence;
    import java.io.Serializable;
    import java.lang.String;
    import java.util.List;
    import javax.persistence.*;

   /**
   * Entity implementation class for Entity: Forum
   *
   */
   @Entity

 public class Forum implements Serializable {


private int idForum;
private String sujet;
private String message;
private List<Journaliste> journalistes;
private List<UtilisateurInscrit> utilisateurinscrit;
private List<Admin> admins; 
private static final long serialVersionUID = 1L;

public Forum() {
    super();
}   
@Id   
@GeneratedValue(strategy=GenerationType.IDENTITY)
public int getIdForum() {
    return this.idForum;
}

public void setIdForum(int idForum) {
    this.idForum = idForum;
}   
public String getSujet() {
    return this.sujet;
}

public void setSujet(String sujet) {
    this.sujet = sujet;
}   
public String getMessage() {
    return this.message;
}

public void setMessage(String message) {
    this.message = message;
}
@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + idForum;
    result = prime * result + ((message == null) ? 0 : message.hashCode());
    result = prime * result + ((sujet == null) ? 0 : sujet.hashCode());
    return result;
}

@OneToMany(mappedBy = "forum")
public List<Journaliste> getJournalistes() {
    return journalistes;
}

public void setJournalistes(List<Journaliste> journalistes) {
    this.journalistes = journalistes;
}
@OneToMany(mappedBy = "forum")
public List<UtilisateurInscrit> getUtilisateurInscrits() {
    return utilisateurinscrit;
}

public void setUtilisateurInscrits(List<UtilisateurInscrit>      utilisateurinscrit) {
    this.utilisateurinscrit = utilisateurinscrit;
}

@OneToMany(mappedBy = "forum")
public List<Admin> getAdmins() {
    return admins;
}

public void setAdmins(List<Admin> admin) {
    this.admins = admin;
}

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Forum other = (Forum) obj;
    if (idForum != other.idForum)
        return false;
    if (message == null) {
        if (other.message != null)
            return false;
    } else if (!message.equals(other.message))
        return false;
    if (sujet == null) {
        if (other.sujet != null)
            return false;
    } else if (!sujet.equals(other.sujet))
        return false;
    return true;
   }

  }

ADMIN.JAVA:

    package edu.app.persistence;

    import java.io.Serializable;


    import javax.persistence.Entity;

     @Entity
     public class Admin extends User implements Serializable{

     private static final long serialVersionUID = -6762162980207739005L;


     private int adminLevel;



  public Admin() {
   }



  public Admin(String login, String password, String email,Forum forum,int   adminLevel) {
    super(login, password,email,forum);
    this.setAdminLevel(adminLevel);
    }


    public int getAdminLevel() {
      return adminLevel;
     }

    public void setAdminLevel(int adminLevel) {
      this.adminLevel = adminLevel;
    }



     }

当我尝试运行我的服务器时,我收到此错误:

  

org.hibernate.AnnotationException:mappedBy引用未知的目标实体属性:edu.app.persistence.Formin.admins中的edu.app.persistence.Admin.forum

我的工作有什么问题?

0 个答案:

没有答案