title: JPA / Hibernate Select Column Subset on Join
body: <p>In SQL it is easy to do a join and only return the columns you want from the joined table. What is the best way to map this in JPA / Hibernate?</p>
  
  <p>For example, there is a Folder entity mapped to the EMAIL_FOLDER and an Email entity mapped to the EMAIL table. There is a one-to-many relationship from Folder to Email. The Email entity is rather heavy because it contains CLOBs of the text, attachments, etc. There are some cases where we need to get the whole Email back and there are other cases when we just want to bring back senderName, subject, and sentDate and do not want the memory overhead of bringing in the CLOB data. Accomplishing this in SQL is straightforward, but I'm not sure what the best approach would be in JPA / Hibernate. </p>
  
  <p>I'm thinking about creating a LightEmail that only maps to senderName, subject, and sentDate. Is this the best way to handle something like this?</p>
  
  <p>Update: At this point I'd like to avoid byte code instrumentation if possible.</p>