See also: http://stackoverflow.com/questions/11698488/unable-to-query-with-mapsid-and-id-but-works-just-with-id
I have two entities, one of which uses the other's PK as its own:
@Entity public class Firm { ... @Id @Column(...) public Long getId() {...} ... } @Entity public class FirmContactInfo { ... @Id public Long getId() {...}
@OneToOne @MapsId @JoinColumn(...) public Firm getFirm() {...}
}
Attempting a query such as the following results in "Missing IN or OUT parameter at index:: 1"
Firm f = em.find(Firm.class, 1461L); assertNotNull(f); TypedQuery<FirmContactInfo> q = em.createQuery( "SELECT fci " + "FROM FirmContactInfo fci " + "WHERE fci.firm IN (:firms)", FirmContactInfo.class); q.setParameter("firms", f); FirmContactInfo fci = q.getSingleResult(); assertNotNull(fci);
Pulling out Firm ids and searching based on FirmContactInfo.id does work, but that's not always convenient.
|