title: Caused by: org.hibernate.MappingException: Repeated column in mapping for entity
body: <p>I am beginner in handling JPA with maven and JBOSS, with Restful to make my application I have the following problem arose me doing DEPLOY</p>
  
  <pre><code>Caused by: javax.persistence.PersistenceException: [PersistenceUnit: com.company.test_resources_war_1.0-SNAPSHOTPU] Unable to build EntityManagerFactory
       Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: database.Photo column: fid_module (should be mapped with insert = \ "false \" update = \ "false \") "}}
  </code></pre>
  
  <p>Not that step, check all posles solutions, but did not find anything, can someone help me??</p>
  
  <p>Thanks in advance</p>
  
  <p>Below I show the SQL code in postgres that I have and I did the mapping.</p>
  
  <p>I have three tables (<strong>activity</strong>, <strong>event</strong> and <strong>photo</strong>) where one of them (<strong>photo</strong>) refers to the other two (<strong>activity</strong> and <strong>event</strong>) but in a single column (<strong>photo.fid_module</strong>)</p>
  
  <p>SQL Code (enginer database-->Postgresql):</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE activity (
    id_activity integer not null,
    name character varying(150),
    description text,
    CONSTRAINT id_activity_pk PRIMARY KEY (id_activity)
  )
  
  CREATE TABLE event (
    id_event integer not null,
    name character varying(150),
    description text,
    date timestamp without time zone,
    CONSTRAINT id_event_pk PRIMARY KEY (id_event)
  )
  
  CREATE TABLE photo(
    id_photo integer not null,
    path character varying(150),
    fid_module integer not null,
    CONSTRAINT id_photo_pk PRIMARY KEY (id_photo),
    CONSTRAINT fk_photo_activity FOREIGN KEY (fid_module)
        REFERENCE activity (id_activity) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION,
    CONSTRAINT fk_photo_event FOREIGN KEY (fid_module)
        REFERENCE event (id_event) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  </code></pre>
  
  <p>Now the mapping I did with the help of Netbenas and gave me the following code (I did the mapping for the three tables, but in presenting me the problem is in the class <strong>Photo.java</strong>).</p>
  
  <pre><code>@Entity
  @Table(name = "photo")
  @XmlRootElement
  @NamedQueries({
      @NamedQuery(name = "photo.findAll", query = "SELECT p FROM Photo p"),
      @NamedQuery(name = "photo.findByFidPhoto", query = "SELECT p FROM Photo p WHERE p.fidphoto = :fidphoto"),
      @NamedQuery(name = "photo.findByIdPhoto", query = "SELECT p FROM Photo p WHERE p.idphoto = :idphoto")})
  public class Photo implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(name = "id_photo")
      private Integer idPhoto;
      @Column(name = "path")
      private Recurso fidPath;
      @JoinColumn(name = "fid_module", referencedColumnName = "id_activity")
      @ManyToOne(optional = false, fetch = FetchType.LAZY)
      private SliderWebHome fidModule;
      @JoinColumn(name = "fid_module", referencedColumnName = "id_event")
      @ManyToOne(optional = false, fetch = FetchType.LAZY)
      private Publicacion fidModule1;
  
      public ModuloRecurso() {
      }
      .......
  }
  </code></pre>
  
  <p>I am using JPA for persistence (but do mvn clean install and <strong>mvn jboss-as: deploy</strong> several pulls me hibernate dependencies) could anyone tell me what is my mistake or could solve this problem. Thank you.</p>