Migration to Hibernate 6 breaks our code. EntityManager.merge sets the id on the original transient entity while Hibernate 5 does not

In Hibernate 5.6.14, calling entityManager.merge(entity) with a transient entity retains entity.id = null after the call.
After migration to Hibernate 6.3.1, the same call seems to modify the entity and sets id to a generated value.

I cannot find any clues in docs for why this has been changed.

In our case, it breaks our existing code after migration, since we interpret a non-null id to indicate that the entity has been persisted and a null id indicating it is a new entity (in which we perform additional logic).

It’s a bug. See HHH-17634 Merging a new entity having a @GeneratedValue id should not set the generated id to the original entity by dreab8 · Pull Request #7698 · hibernate/hibernate-orm · GitHub and [HHH-17634] - Hibernate JIRA