title: JPA find from composite Key
body: <p>I have a class like this...</p>
  
  <pre><code>@Entity
  public class User{
    private String userId;
    @Id
    public String getUserId(){
      return userId;
    }
    public void setUserId(String userId){
      this.userId = userId;
    }
  }
  
  @Embeddible
  public class RegPk{
    private String serial;
    private String userId;
    ....
  }
  
  @Entity
  @IdClass(RegPk.class)
  public class Registration {
    private String userId, serial;
  
    private User user
  
    @Id
    @Column(name="SRL_C")
    public String getSerial() {return serial;}
    public void setSerial(String serial) {this.serial = serial;}
    @ManyToOne(cascade={CascadeType.REFRESH})
    @JoinColumn(name="USERID", referencedColumnName="USERID", nullable = false)
    public User getUser() {return user;}
    public void setUser(User user) {this.user = user;}
    @Id
    @Column(name="USERID", nullable = false)
    public String getUserId() {
      return userId;
    }
    public void setUserId(String userId) {
      this.userId = userId;
    }
  
  }
  
  RegPk pk = new RegPk();
  pk.setSerial(dr.getSerial());
  pk.setUserId(dr.getUserId());
  Registration userOld =  em.find(Registration.class, pk);
  </code></pre>
  
  <p>But when I try to run it I get null back. I swear I thought I had it working so...</p>
  
  <p>1.) is this kind of thing even possible?
  2.) what am I doing wrong?</p>