OPENJPA-2539: Query Compilation causing inner join table to be randomly generated incorrectly - ported changes to trunk.