HHH-8683 EntityEntry backport on master

Hey @gunnarmorling and @sanne
I had to make a few adjustments to port it to master, can you double check it.
(new pull request on the correct repo)
Is the "extra == null" required here?

Couldn't it be the following, retrieving extra only if required:

    if ( deletedState == DEFAULT_DELETED_STATE ) {
        //this is the default value and we do not store the extra state
        return;
    }
    EntityEntryExtraStateHolder extra = getExtraState( EntityEntryExtraStateHolder.class );
    if ( extra == null ) {
        extra = new EntityEntryExtraStateHolder();
        addExtraState( extra );
    }
    extra.setDeletedState( deletedState );