Hibernate version: 3.1.x
When I have a mapped composite-id, e.g.:
Code:
<class name='T1' table='t1'>
<composite-id mapped='true' class='T1$Id'>
<key-property name='id'/>
<key-property name='validFrom' type='imm_timestamp'/>
</composite-id>
<property name='t3'/>
</class>
and I make a HQL query on a part of the composite-id, such as:
Code:
from T1 h where h.id=10 order by h.validFrom
the result is an invalid query:
Quote:
select ... from pms.t1 t10_ where (t10_.id, t10_.valid_from)=10 order by t10_.valid_from
As you see, even though the
mapped composite-id class is backed by individual properties on the T1 class (id and validFrom in this case), the query treats them as a single block and won't generate a query on id alone. It always wants to consider id and validFrom together.
It is not uncommon to make a query on just a part of a composite primary key, but it seems impossible in HQL.
Should this be considered a bug or undesired behaviour? Any workarounds? It makes the mapped composite-id kind of useless in my opinion.