Make sure session creation is inside a transaction