In Hibernate 7 @Persister Annotation was removed. What is the alternative?

Hi Team!

In previous Hibernate versions, we used our CustomEntityPersister (s) to implement additional logic for the Insert and Update operations.

In the Hibernate 7 migration guide, I see that only this annotation was removed without any alternatives.

What is the reason for removing it?
Perhaps I can restore this annotation using legacy processing logic in my project?

I have found that the PersisterClassResolver class is now responsible for setting the EntityPersister for the class.
But I did not find any examples of how to use it.

Should I extend PersisterClassResolver?
How then to register a new CustomPersisterClassResolver?

I am thinking about creating the annotation in project with the same Name and Parameters, and then in CustomPersisterClassResolver retrieve EntityPersister from the annotation parameter.
Will it work?

Any code examples and suggestions will be helpful.

Thank you!

A somewhat related question was asked in the past, but the real question is, why do you need a custom persister?

To implement additional logic for the Insert and Update operations.

Possibly, there is a better way to do this.

But now we just want to know if my assumption with PersisterClassResolver will work?

Like I answered in the thread I linked, using a PersisterClassResolver will work. Can you please share what additional logic you need to do so we actually now the use cases. Making it harder to replace persisters was done because they touch so many internals and it’s unreasonable for a user to implement them. We want to understand what drives you to do it anyway and see if we can improve something so that you don’t have to.