title: JPA OneToMany mapping exception: Field XXX cannot declare that it is mapped by another field
body: <p>In my project I have the classes reported below, with a bidirectional relationship mapping. When I try to read an object of type DataProviderImpl through JPA I got the following exception:</p>
  
  <blockquote>
    <p> org.apache.openjpa.persistence.ArgumentException: Field "persistence.entity.DataProviderImpl.methods" cannot declare that it is mapped by another field. Its mapping strategy( org.apache.openjpa.jdbc.meta.strats.HandlerCollectionTableFieldStrategy) does not support mapping by another field.</p>
  </blockquote>
  
  <p>I have already checked other questions, but nothing seems to apply in my case. Any hints?
  Thank you in advance!</p>
  
  <pre><code>&lt;persistence
  xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0"&gt;
  
  &lt;persistence-unit name="DataProvider" transaction-type="JTA"&gt; &lt;!-- transaction-type="RESOURCE_LOCAL"  info at:  http://tomee.apache.org/jpa-concepts.html --&gt;
      &lt;jta-data-source&gt;
          osgi:service/jdbc/mysqlPoolXAds
      &lt;/jta-data-source&gt;
      &lt;non-jta-data-source&gt;
          osgi:service/jdbc/mysqlds
      &lt;/non-jta-data-source&gt;      
      &lt;class&gt;persistence.entity.DataProviderImpl&lt;/class&gt;
      &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  &lt;persistence-unit name="RestMethod" transaction-type="JTA"&gt; &lt;!-- transaction-type="RESOURCE_LOCAL"  info at:    http://tomee.apache.org/jpa-concepts.html --&gt;
      &lt;jta-data-source&gt;
          osgi:service/jdbc/mysqlPoolXAds
      &lt;/jta-data-source&gt;
      &lt;non-jta-data-source&gt;
          osgi:service/jdbc/mysqlds
      &lt;/non-jta-data-source&gt;      
      &lt;class&gt;persistence.entity.RestMethodImpl&lt;/class&gt;
      &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <h2></h2>
  
  <pre><code>@Entity(name = "DataProvider")
  public class DataProviderImpl implements DataProvider {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int id;
      private String name;
      // ...
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy="dataProvider")
      private List&lt;RestMethod&gt; methods;
  
  
      public DataProviderImpl() {
          super();
          this.id = 0;
      }
  
      @Override
      public int getId() {
          return id;
      }
      @Override
      public void setId(int id) {
          this.id = id;
      }
      @Override
      public String getName() {
          return name;
      }
      @Override
      public void setName(String name) {
          this.name = name;
      }
      @Override
      public List&lt;RestMethod&gt; getMethods() {
          return methods;
      }
      @Override
      public void setMethods(List&lt;RestMethod&gt; methods) {
          this.methods = methods;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>    public interface DataProvider {
      public int getId();
      public void setId(int id);
      public String getName();
      public void setName(String name);
      public List&lt;RestMethod&gt; getMethods();
      public void setMethods(List&lt;RestMethod&gt; methods);
  }
  </code></pre>
  
  <hr>
  
  <pre><code>    @Entity(name = "RestMethod")
  public class RestMethodImpl implements RestMethod {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int id;
      private String nickname;
      // ...
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name="dataProviderId")
      private DataProvider dataProvider;
  
      public RestMethodImpl() {
          super();
          this.id = 0;
      }
  
      @Override
      public int getId() {
          return id;
      }
      @Override
      public void setId(int id) {
          this.id = id;
      }
      @Override
      public String getNickname() {
          return nickname;
      }
      @Override
      public void setNickname(String nickname) {
          this.nickname = nickname;
      }
      @Override
      public DataProvider getDataProvider() {
          return dataProvider;
      }
      @Override
      public void setDataProvider(DataProvider dataProvider) {
          this.dataProvider = dataProvider;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>    public interface RestMethod  {
      public int getId();
      public void setId(int id);
      public String getNickname();
      public void setNickname(String nickname);
      public DataProvider getDataProvider();
      public void setDataProvider(DataProvider dataProvider);
  }
  </code></pre>