fix exportScope, refactor setPrimaryKey

exportScope wasn't exporting owned beans when the bean key was passed.
Also refactored it a bit to make the code a bit clearer (not so many
nested ifs).

setPrimaryKey was changed to always cascade the primary key to owned
beans.
cascadePrimaryKey was made private