Indeed, replacing the selecting of the compound primary key fields by selecting constant value 1 does solve problem. I'm quite sure I tested this before changing the genrated SQL query by hand when I created the question in the forum.