Added offset to buildQuery, fixed ordering by parameters
setEntity now checks that the entity is of the correct kind and sets the ID from the entity