Versioning issues on session.flush

Hey, opening a pull request with some fixes related to mid-transaction flushes. Check the added tests to see what I think the expected behavior should be
- Keep the version's type as INSERT when a new object is flushed and then modified within the same single transaction. Currently there is no insert entry ever created.
- Ensure the same versioning behavior when primary keys of objects are modified after a flush, with the behavior that you get when they are modified without a flush.

Yet to fix:
- When a new object is created, flushed, then deleted (all in the same transaction), I would expect no version entry to be saved.
- Postgres native versioning has received no modifications.