fixed wrong sql query generation in refObjectMap

Check sql query for "order by" keyword before inserting "where"
condition in refObjectMap definitions with a joinCondition