title: How to make a query using columns of a JoinTable in Rest Webservice with netbeans
body: <p>How I can to do this query:
  <code>@NamedQuery(name = "Scuser.findFriends", query = "SELECT s FROM Scuser s, friends f WHERE f.firstid = :iduser and s.iduser = f.secondid")</code></p>
  
  <p>in this class:</p>
  
  <pre><code>@Entity
  @Table(name = "scuser")
  @XmlRootElement
  @NamedQueries({
   @NamedQuery(name = "Scuser.findAll", query = "SELECT s FROM Scuser s"),
   @NamedQuery(name = "Scuser.findByIduser", query = "SELECT s FROM Scuser s WHERE s.iduser = :iduser"),
      @NamedQuery(name = "Scuser.findByUpassword", query = "SELECT s FROM Scuser s WHERE s.upassword = :upassword"),
      @NamedQuery(name = "Scuser.findByUname", query = "SELECT s FROM Scuser s WHERE s.uname = :uname"),
      @NamedQuery(name = "Scuser.findByTpoints", query = "SELECT s FROM Scuser s WHERE s.tpoints = :tpoints"),
  //    @NamedQuery(name = "Scuser.findFriends", query = "SELECT s FROM Scuser s, friends f WHERE f.firstid = :iduser and s.iduser = f.secondid"),
      @NamedQuery(name = "Scuser.findByUnameUpassword", query = "SELECT s FROM Scuser s WHERE s.uname = :uname and s.upassword = :upassword")})
  public class Scuser implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Basic(optional = false)
      @NotNull
      @Size(min = 1, max = 2147483647)
      @Column(name = "iduser")
      private String iduser;
      @Size(max = 200)
      @Column(name = "upassword")
      private String upassword;
      @Size(max = 200)
      @Column(name = "uname")
      private String uname;
      // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
      @Column(name = "tpoints")
      private Double tpoints;
      @JoinTable(name = "friends", joinColumns = {
          @JoinColumn(name = "firstid", referencedColumnName = "iduser")}, inverseJoinColumns = {
          @JoinColumn(name = "secondid", referencedColumnName = "iduser")})
      @ManyToMany
      private Collection&lt;Scuser&gt; scuserCollection;
      @ManyToMany(mappedBy = "scuserCollection")
      private Collection&lt;Scuser&gt; scuserCollection1;
      @ManyToMany(mappedBy = "scuserCollection")
      private Collection&lt;Beach&gt; beachCollection;
  
  public Scuser() {
  }
  
  public Scuser(String iduser) {
      this.iduser = iduser;
  }
  
  public String getIduser() {
      return iduser;
  }
  
  public void setIduser(String iduser) {
      this.iduser = iduser;
  }
  
  public String getUpassword() {
      return upassword;
  }
  
  public void setUpassword(String upassword) {
      this.upassword = upassword;
  }
  
  public String getUname() {
      return uname;
  }
  
  public void setUname(String uname) {
      this.uname = uname;
  }
  
  public Double getTpoints() {
      return tpoints;
  }
  
  public void setTpoints(Double tpoints) {
      this.tpoints = tpoints;
  }
  
  @XmlTransient
  public Collection&lt;Scuser&gt; getScuserCollection() {
      return scuserCollection;
  }
  
  public void setScuserCollection(Collection&lt;Scuser&gt; scuserCollection) {
      this.scuserCollection = scuserCollection;
  }
  
  @XmlTransient
  public Collection&lt;Scuser&gt; getScuserCollection1() {
      return scuserCollection1;
  }
  
  public void setScuserCollection1(Collection&lt;Scuser&gt; scuserCollection1) {
      this.scuserCollection1 = scuserCollection1;
  }
  
  @XmlTransient
  public Collection&lt;Beach&gt; getBeachCollection() {
      return beachCollection;
  }
  
  public void setBeachCollection(Collection&lt;Beach&gt; beachCollection) {
      this.beachCollection = beachCollection;
  }
  
  @Override
  public int hashCode() {
      int hash = 0;
      hash += (iduser != null ? iduser.hashCode() : 0);
      return hash;
  }
  
  @Override
  public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Scuser)) {
          return false;
      }
      Scuser other = (Scuser) object;
      if ((this.iduser == null &amp;&amp; other.iduser != null) || (this.iduser != null &amp;&amp; !this.iduser.equals(other.iduser))) {
          return false;
      }
      return true;
  }
  
  @Override
  public String toString() {
      return "REST.Scuser[ iduser=" + iduser + " ]";
  }
  </code></pre>
  
  <p>}</p>