I would like to add some code in save method in CrudRepository
but keep orginal functionality. After that save method should do what before, save to repository but additionally execute extra action. Is it possible? If so, how could I do it properly?
Thank you in advance for any tips
Edit
So, I would like to create method like this:
@Override
public default <S extends MyClass> S save(S myClassItem) {
//here my functionality
super.save(myClassItem); //from CrudRepository
return myClassItem;
}
I don't think it's possible to user super in such a method (default and overridden). So you must change the name of the method - which might not be exactly what you are looking for :
public interface TestRepository extends CrudRepository<MyClass, String> {
default MyClass mySave(MyClass myClassItem) {
save(myClassItem);
return myClassItem;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With