Hibernate version: 3.2.1.GA
I have two old tables
Code:
table certificate
cert_ky bigint primaryKey
Code:
table NAME
NME_KY bigint primarykey,
nme_rlt_tbl_nm varchar,
nme_rlt_ky bigint,
NME_LST_NM varchar,
NME_GVN_NM varchar
and I have two entity class
Code:
@Entity
@Table(name="CERTIFICATE")
class Certificate {
@Id
@GeneratedValue
@Column(name = "crt_ky")
private Long certKey;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "crt_ky", referencedColumnName = "NME_RLT_KY")
private Name name;
.......
}
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "NME_RLT_TBL_NM", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("certificate")
@Table(name = "NAME")
public class Name implements Serializable {
private static final long serialVersionUID = -1060132506269104470L;
@Id
@GeneratedValue
@Column(name = "NME_KY")
private Long nameKey;
@Column(name = "NME_GVN_NM", length = 50)
private String givenName;
@Column(name = "NME_LST_NM", length = 50)
private String lastName;
@OneToOne
@JoinColumn(name = "NME_RLT_KY", referencedColumnName = "crt_ky", insertable = false, updatable = false)
private Certificate certificate;
.......
}
That means one CERTIFICATE has a NAME with NME_RLT_TBL_NM = 'certificate' and NME_RLT_KY = CERTIFICATE.CERT_KY
The problem is when I run HQL
Code:
select name from Certificate
It give me this result
Code:
select
name1_.NME_KY as NME2_120_,
name1_.NME_RLT_KY as NME5_120_,
name1_.NME_GVN_NM as NME3_120_,
name1_.NME_LST_NM as NME4_120_
from
CERTIFICATE certificat0_
inner join
NAME name1_
on certificat0_.crt_ky=name1_.NME_KY
What I am expecting is
inner join
NAME name1_
on certificat0_.crt_ky=
name1_.NME_RLT_KY
Why it ignore
referencedColumnName = "NME_RLT_KY" in the Certificate class?