While testing an application we had to see, Castor has sometimes problems to
read objects with master-detail connections. It doesn't find all children
records in arrays, vectors or any other collections.
I traced down this problem to the functions nextIdentity() and fetchRaw() in
class SQLEngine. This functions expect datasets with equal identity keys
(e.g. "PKA") to be fetched in continuous order.
But this guaranteed for SQL statements like:
select A.PKA, B.PKB
from A, B
where A.PKA = B.PKA
This is at least the behaviour of Oracle databases.
I am not sure about other systems.
So I implemented the fix only for the class OracleQueryExpression.
May be other DBs also they need a similar fix.
The attached patch adds an explicit explicit sort order using the identity
columns when joining tables to make dataset order predictable.
If there is specified an other ORDER BY expression, this is not changed.