Bug: A above exception thrown when using hibernate.
Reason: This error occurs usually because of a misplaced “order by” clause.
If in a many to many mapping, the serial order is defined in the cross reference table, the order-by attribute should be provided in the “collection” node as below –
<bag name="projects" ... table="users_projects" inverse="true" order-by="sl_num"> <key column="userId"/> <many-to-many column="projectId" class="Project"/> </bag>
On other hand, if the collection is to be sorted by a column defined in the collection member, the order-by should be provided in the many-to-many or one-to-many node, as shown below.
<bag name="projects" ... table="users_projects" inverse="true"> <key column="userId"/> <many-to-many column="projectId" class="Project" order-by="name"/> </bag>
Solution: Move the order-by attribute to appropriate node depending on which table holds the sorted field.