Hi,
I have a problem to force Hib. (3.2.5.ga) to load some "specific" many-to-one associations by lazy strategy.
I have table X:
CREATE X (
ID VARCHAR2(10) NOT NULL, -- PK
CODE NUMBER(10) ,
CODE_REF1 NUMBER(10),
CODE_REF2 NUMBER(10)
)
;
where x.CODE_REF1 and x.CODE_REF2 are "inner" foreign key references (references to records of the same table, I will not include FK constraints here).
Problematic mapping sections are defined as smth. like that:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CODE_REF1", referencedColumnName = "CODE", nullable = true, insertable = false, updatable = false)
public X getXByRef1() {
return xByRef1;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CODE_REF2", referencedColumnName = "CODE", nullable = true, insertable = false, updatable = false)
public X getXByRef2() {
return xByRef2;
}
When I load "parent" entity X by id, hibernate always cause automatically initialize these two child associations (and then their inner references as well and so on as deep as references exists) of the given entity.
When I remove 'referencedColumnName = "CODE"' from configuration (link entities through PK field "ID") then these properties seems to have proxy objects assigned (as I expect) and lazy constructions work fine.
Any comments, why does not it succeed with "referencedColumnName" parameter in configuration?
Thnks,
Ilhan
|