Pas*_*ent 15
这应该可以使用多对一的公式.来自第5.1.22节.列和公式元素(前一个答案中也提到了解决方案):
column和formula属性甚至可以在同一属性或关联映射中组合,以表示例如异国连接条件.Run Code Online (Sandbox Code Playgroud)<many-to-one name="homeAddress" class="Address" insert="false" update="false"> <column name="person_id" not-null="true" length="10"/> <formula>'MAILING'</formula> </many-to-one>
使用注释(如果您使用的是Hibernate 3.5.0-Beta-2 +,请参阅HHH-4382):
@ManyToOne
@Formula(value="( select v_pipe_offerprice.offerprice_fk from v_pipe_offerprice where v_pipe_offerprice.id = id )")
public OfferPrice getOfferPrice() { return offerPrice; }
Run Code Online (Sandbox Code Playgroud)
或者查看@JoinColumnsOrFormula:
@ManyToOne
@JoinColumnsOrFormulas(
{ @JoinColumnOrFormula(formula=@JoinFormula(value="SUBSTR(product_idnf, 1, 3)", referencedColumnName="product_idnf")) })
@Fetch(FetchMode.JOIN)
private Product productFamily;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12610 次 |
| 最近记录: |