title: Apache OpenJPA - NamedQuery Exception
body: <p>I hava two tables with a manyToMany relation :</p>
  
  <pre><code>@Entity(name = "arelation")
  @NamedQueries({ @NamedQuery(name = "arelation.findAByName", query = "SELECT a FROM arelation a WHERE a.arelationname = :aname"),
      @NamedQuery(name = "arelation.findA", query = "SELECT a FROM arelation a WHERE a.arelationname = :aname and a.bList = :bList")
  })
  public class ABean{
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      @NotNull
      private String arelationname;
  
      @ManyToMany(targetEntity = BBean.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
      @JoinTable(name = "joinAB", joinColumns = { @JoinColumn(name = "aID") }, inverseJoinColumns = { @JoinColumn(name = "bID") })
      private List&lt;BBean&gt; bList= new ArrayList&lt;BBean&gt;();
  
          .......
  }
  
  @Entity(name = "brelation")
  @NamedQueries({ @NamedQuery(name = "brelation.findB", query = "SELECT b FROM brelation b WHERE b.brelationname = :bname)})
  public class BBean{
      /*
       * private Bean Variables
       */
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      @NotNull
      private String brelationname;
  
  
      @ManyToMany(mappedBy = "bList")
      @NotNull
      private List&lt;ABean&gt; aList= new ArrayList&lt;ABean&gt;();
  
          .......
  }
  </code></pre>
  
  <p>No I want to find a ABean with the NamedQuerd arelation.findA like this:</p>
  
  <pre><code>public ABean findABean(EntityManager em, ABean a)
          throws NoResultException {
      return  (ABean) em.createNamedQuery("arelation.findA")
              .setParameter("aname", a.getArelationname())
              .setParameter("blist", a..getBList())
              .getSingleResult();
  }
  </code></pre>
  
  <p>I set the bList with persisted objects from the database.</p>
  
  <p>But when I want to find the "ABean" i get following Exception:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Parameter "Parameter&lt;BBean&gt;('blist')" declared in "SELECT a FROM arelation a WHERE a.arelationname = :aname and a.bList = :bList" is set to value of "[     ArelationName: name0
  ,       ArelationName: name1
  ,       ArelationName: name2
  ,       ArelationName: name3
  ,       ArelationName: name4
  ,       ArelationName: name5
  ,       ArelationName: name6
  ,       ArelationName: name7
  ]" of type "org.apache.openjpa.util.java$util$ArrayList$proxy", but this parameter is bound to a field of type "mypackage.BBean"
  </code></pre>
  
  <p>Does someone know why I get this Exception?
  I only want to know, if the ABean with this name and this BBeans exists in the DB.</p>
  
  <p>EDIT:
  Ok, I know the reason:
  The Parameter should be a BBean and not a List of it.
  But how can I use a List of BBeans?</p>
  
  <p>Best Regards
  Veote</p>