Hey guys,
I am trying to use annotations with a sql View.
There is no unique keys in Views, so I am trying to build a composite @Id.
The problem is that the two columns that I want to annotate are both @ManyToOne.
Is there a way to do this? I'm finding it hard to find any information on this in the forums or documentation.
Code:
@SuppressWarnings("serial")
@Entity
@Table(name = "vPhysicianPanelPayment", schema = "dbo")
@IdClass(value = PhysicianPanelPaymentCompositePk.class)
public class PhysicianPanelPayment extends DomainObject {
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PanelMembershipUID", nullable = false)
private PanelMembership panelMembership;
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PhysicianUID", nullable = false)
private Physician physician;
...
...
}
@Embeddable
class PhysicianPanelPaymentCompositePk implements Serializable {
private PanelMembership panelMembership;
private Physician physician;
public PanelMembership getPanelMembership() {
return panelMembership;
}
public Physician getPhysician() {
return physician;
}
public void setPanelMembership(PanelMembership panelMembership) {
this.panelMembership = panelMembership;
}
public void setPhysician(Physician physician) {
this.physician = physician;
}
}
Thanks so much.