Using the code event listener is preferred as it is less susceptible to mistakes that might prevent other pre save code from running. However, if you already have to extend the class, for example to add additional methods to the entity, then just extending the class and the required methods is acceptable.