I've used "order-by" when mapping 1-n relation to a bag several times with no issues. Trying to do so with a n-m relation unfortunately doesn't work.
In the example below I try to get the tags related to a document sorted by name.
Code:
<bag name="tags" access="field" table="document_tags" inverse="false" lazy="true" cascade="all-delete-orphan" order-by="Name">
<key>
<column name="document_id" sql-type="int" not-null="true" />
</key>
<many-to-many class="MiddleLayer.Domain.Tag, MiddleLayer">
<column name="tag_id" sql-type="int" not-null="true" />
</many-to-many>
</bag>
If the order-by="Name" is present, the SQL that is generated prefixes the "Name" column with tha alias of the "document_tags" table. That means that it tries to sort with a "Name" column from the intermediate table instead of the "tags" table.
Is this a bug? Am I doing something wrong?
Tia,
Nikos.