Hello 8),
I currently have the need to order a query by a specific field in a composite foreign key (ordering by the foreign key itself would be ok),
the foreign key mapping is as follows:
Code:
<many-to-one
name="conta"
class="com.whateversoft.conta.business.entities.ContaVO"
cascade="none"
outer-join="false"
update="true"
insert="true"
not-null="false">
<column name="CodConta" not-null="false"/>
<column name="CodPlano" not-null="false"/>
</many-to-one>
A Criteria is being used to filter the results and if it's added the following line :
Code:
criteria.addOrder (Order.asc ("conta"));
I get an error saying that ordering by composite values is not allowed.
I can't acess the columns by themselves; If I add the following order:
Code:
criteria.addOrder (Order.asc ("conta.contaId.codigo"));
Being contaId ContaVO's property name of class ContaId (containing the composite key values), and codigo being ContaId's property name of type String and mapped to the first part of the composite key of table conta.
The question is... is it possible to order a table by a composite foreign key? if so, how? if not; is it possible to order a table by a part of a composite foreign key? if so, how?
thanks :)
v.