You can map the fk columns explicitly, i.e.
@Entity
@IdClass(StationPK.class)
public class Station{
EntA a;
EntB b;
Integer aPk;
Integer bPk;
@Id
@Column(name="APK")
Integer getAPk() {...}
@ManyToOne(...)
@JoinColumn(name="APK", insertable="false", updatable="false")
public EntA getA(){ ... }
@Id
@Column(name="BPK")
Integer getBPk() {...}
@ManyToOne(...)
@JoinColumn(name="BPK", insertable="false", updatable="false")
public EntB getB(){ ... }
}
The IdClass definition would stay the same. Note, that the relationship must be mapped "readOnly", as the relationships are defined when setting the primary key and can not be updated.
[Message sent by forum member 'mf125085' (mf125085)]
http://forums.java.net/jive/thread.jspa?messageID=216541