In a transaction where many entities are inserted, the performance when getting an entity is degrading at:
insertedEntityIds list may contain more than 100.000 entries that affect performance of ArrayList.contains which has O( n ) complexity.
Please replace ArrayList with HashSet for better contains performance.
I've refactored StatefulPersistenceContext#registerInsertedKey and StatefulPersistenceContext#wasInsertedDuringTransaction
to use HashSet instead of ArrayList.