Hi,
I have three entities A, B, and C.
Code:
@Entity
public class A implements java.io.Serializable {
@Id
private String s;
...
}
@IdClass(BKey.class)
@Entity
public class B implements java.io.Serializable {
@Id
@Temporal(javax.persistence.TemporalType.DATE)
private Date pDate;
@Id
@ManyToOne
private A a;
@Id
protected int cInt;
...
}
@IdClass(CKey.class)
@Entity
public class C implements java.io.Serializable {
@Id
@Temporal(javax.persistence.TemporalType.DATE)
private Date pDate;
@Id
@ManyToOne
private A a;
...
}
I want to introduce OneToOne unidirectional read-only relationship with source being B and target being C. How would I do that?
I tried declaring C field in B as follows:
Code:
@OneToOne
@JoinColumns({
@JoinColumn(name="A_S",referencedColumnName="A_S",insertable=false,updatable=false),
@JoinColumn(name="PDATE",referencedColumnName="PDATE",insertable=false,updatable=false)})
protected C c;
However, every query to load B leaves field C as null. What am I doing wrong?
Thank you!