Unable to persist custom attributes in custom authenticator

Hi
I built a custom password reset authenticator used to store a counter of reset actions made for a user.
So I want to store this counter in a custom user attribute, something like that :
user.setSingleAttribute(COUNTER_ATTRIBUTE, newcounter);
context.forkWithSuccessMessage(new FormMessage(Messages.EMAIL_SENT));

When I test it on my local keycloak (dev mode) it works perfectly
But in production the attribute is never persisted in database, it stays in session only.
What could be the problem ?

I’ve tried a solution found in another post, but it gives me big hibernate errors :
KeycloakModelUtils.runJobInTransaction(
session.getKeycloakSessionFactory(),
s → {
UserModel u = session.users().getUserById(context.getRealm(), user.getId());
u.setSingleAttribute(COUNTER_ATTRIBUTE, newcounter);
u.setSingleAttribute(DATE_ATTRIBUTE, Long.toString(new Date().getTime()));
});