我有如下的一对多关系:
public class Player {
private int id;
private String name;
private List<Payment> payments;
... accessors etc
}
public class Payment {
private int id;
private Date when;
private BigDecimal amount;
... accessors etc
}
orm描述这些:
<entity-mappings ... version="2.0">
<entity class="domain.Player" access="FIELD">
<attributes>
<id name="id">
<generated-value strategy="AUTO" />
</id>
<basic name="name" optional="false" />
<one-to-many name="payments" fetch="EAGER">
<order-by>when</order-by>
<cascade><cascade-all/></cascade>
</one-to-many>
</attributes>
</entity>
<entity class="domain.Payment" access="FIELD">
<attributes>
<id name="id">
<generated-value strategy="AUTO" />
</id>
<basic name="when" optional="false" />
<basic name="amount" optional="false" />
</attributes>
</entity>
</entity-mappings>
这适用于Hibernate 4.2.2.Final,但是如果我更新到4.3.4.Final,每当我尝试加载类型为player的对象时它都会失败。 4.3.4.Final生成的SQL遵循以下行:
select ...
from Player player0_
left outer join Player_Payment payments1_ on player0_.id=payments1_.Player_id
left outer join Payment payment2_ on payments1_.payments_id=payment2_.id
where player0_.id=?
order by payments1_.when
即。 ORDER BY在连接表上,而不是目标表。
任何想法 - 我在这里做错了还是看起来像Hibernate的错误?