Currently, we use the 6.2.31 Hibernate version and we are going to upgrade to 6.6 version.
We extend the AbstractEntityPersister class in our project to apply some custom logic.
In our current Hibernate 6.2 version, these custom EntityPersisters are called from
AbstractEntityPersister is an internal implementation detail as you can see when looking at the class declaration through the @Internal annotation, so changes done to that class are not documented in a migration guide. EntityPersister is an interface that we aim to keep backwards compatible for usage, but if you want to implement it yourself, you have to research the changes and understand how Hibernate ORM uses things.
We introduced the UpdateCoordinator and InsertCoordinator to allow retrieving generated values in a more efficient manner i.e. make use of the returning clause that many SQL dialects offer. Previously, generated values were always fetched after emitting an update through separate operations.
You can figure out these things by using git blame to understand which commits introduced a change, which usually points to a HHH- issue key where you can find further information.
Maybe you can share your use cases that require you to extend these classes in the first place? Ideally, you wouldn’t have to do that and hence also be spared of the upgrade trouble that you’re in right now.
@beikov
Thank you for your quick response.
The main part of this functionality looks like this:
In our application, we have 2 types of DB objects:
“clone” and “original” entities.
When we persist an object we iterate through the linked entities of the current object and change the IDs of these linked objects from “clone” to “original”.
Currently, we do it in the extended class (all below code is simplified):
public class CustomJoinedSubclassEntityPersister extends JoinedSubclassEntityPersister {
public UpdateHandler updateHandler = new UpdateHandler();
@Override
public void update(some fields ..) throws HibernateException {
if (updateHandler.processUpdate(some fields ..)) {
super.update(some fields ..);
}
}
}
And I going to implement in 6.6 something like this.
Does the below implementation of UpdateCoordinatorStandard make sense?
If yes then how can we activate this extended UpdateCoordinator?
public class CustomUpdateCoordinator extends UpdateCoordinatorStandard {
No idea why you’re doing that, but your implementation in principle looks ok to me. You can activate this by returning an instance of that type from EntityPersister#getUpdateCoordinator