criteria: fix issue #2157 (multiple joins)
criteria: added tests for left and right joins
Merge pull request #2220 from maxgalbu/issue2157

criteria: fix issue #2157 and added tests