当尝试对0..1关系使用单向OneToOne
或ManyToOne
关系时,OPENJPA正在生成INNER JOIN而不是LEFT JOIN:
@OneToOne(optional=true, fetch= FetchType.LAZY)
@JoinTable(name="linkThisResult",
joinColumns= {
@JoinColumn(insertable=false, updatable=false, unique=true, nullable=false, name="thisid",referencedColumnName="thisid")
},
inverseJoinColumns= {
@JoinColumn(insertable=false, updatable=false, nullable=false, name="resultid", referencedColumnName="resultid")
}
)
private ResultEntity resultEntity;
给出表格:
result: { resultId, ... }
this : { thisId, ... }
linkThisResult: { linkThisResultId, resultId, thisId, ... }
可选的,可插入/可更新/可空标志都不会影响生成的sql。这是利用OPENJPA 2.2.0。对于没有JoinTable的直接JoinColumns,可选项会更改连接类型。
问题是:如何向OPENJPA表明应该执行LEFT JOIN的等效(理想情况下是懒惰但不是严格的要求)?