better joining management

When querying against primary key, the join is not applied on HasOne or
HasMany relationship if there are no implicit filters in target tables. The primary key value is already known from column referencing target table.
fixed compability for PHP 5.3
updated Entity test