title: possible to return only one column using JPA
body: <p>I have an Open JPA entity and it successfully connects a many-to-many relationship.  Right now I successfully get the entire table, but I really only want the ID's from that tables.  I plan on calling the database later to reconstruct the entities that I need (according to the flow of my program).
  I need only the ID's (or one column from that table).<br>
  1) Should I try and restrict this in my entity beans, or in the stateless session beans that I will be using to call the entity beans
  2) If I try and do this using JPA, how can I specify that I only get back the ID's from the table, instead of the whole table?  So far looking online, I don't see a way that you can do this.  So I am guessing there is no way to do this.
  3) If I simply just manipulate the return values, should I create a separate class that I will be returning to the user that will return only the required id list to the user?  </p>
  
  <p>I could be completely wrong here, but from the looks of it, I don't think there is a simple way to do this using JPA and I will have to return a custom object instead of the entity bean to the user (this custom object would only hold the id's as opposed to the whole table as it currently does)</p>
  
  <p>Any thoughts... I don't think this is really relevant, but people are always asking for code, so here you go...</p>
  
  <pre><code>@ManyToMany(fetch=FetchType.EAGER)
  @JoinTable(name="QUICK_LAUNCH_DISTLIST",
          joinColumns=@JoinColumn(name="QUICK_LAUNCH_ID"),
          inverseJoinColumns=@JoinColumn(name="LIST_ID"))
  private List&lt;DistributionList&gt; distributionlistList;
  </code></pre>
  
  <p>Currently how I get the entire collection of records.  Remember I only want the id...</p>
  
  <pre><code>    try
      {
          //int daSize = 0;
          //System.out.println("Testing 1.2..3...! ");
          qlList = emf.createNamedQuery("getQuickLaunch").getResultList();            
      }
  </code></pre>
  
  <p>This is how I call the Entity beans.  I am thinking this is where I will have to programatically go through and create a custom object similar to the entity bean (but it just has the ID's and not the whole table, and attempt to put the id's in there somewhere. </p>
  
  <p>What are your thoughts?</p>
  
  <p>Thanks</p>