title: EcllipseLink: JPA Entities with same name. Error: Entity name must be unique in a persistence unit
body: <p>I am migrating code from EJB2 to EJB3. I have converted POJOs to JPA Entities. There are few entities have same names such as <strong>@Entity(name="myentity1")</strong>. I am getting error at deployment <strong>"Entity name must be unique in a persistence unit"</strong>. This is happened because <strong>modules have dependencies on other modules</strong> which have entities with same name. Is there any way to interrupt it and update name every time dynamically when it's used (SessionCustomizer or any other way)? I can’t change entity name at this point because entity names are used widely. I am using EcllipseLink 2.5</p>
  
  <p>Sample Code</p>
  
  <p>EJB Module1 (Dependency on EJB Module2)</p>
  
  <pre><code>package com.my.module1.package1;
  
  @javax.persistence.Entity(name = "myentity1")
  @Table(name = "TABLE1")
  public class MyEntity1
      implements Serializable {
  
      @Column(name = "ID")
      private Long Id;
  
      public Long getId() {
      return Id;
    }
  
    public void setId(Long Id) {
      this.Id = Id;
    }
  }
  </code></pre>
  
  <p>//  EJB Module2</p>
  
  <pre><code>package com.my.module2.package2;
  
  @javax.persistence.Entity(name = "myentity1")
  @Table(name = "TABLE1")
  public class MyEntity1
      implements Serializable {
  
      @Column(name = "ID")
      private Long Id;
  
      public Long getId() {
      return Id;
    }
  
    public void setId(Long Id) {
      this.Id = Id;
    }
  }
  </code></pre>
  
  <p>Any help would be much appreciated.</p>