Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does CrudRepository.save return null for spring data 1.13.18.RELEASE

I understand that for the current version(2.x.x) of spring-data-commons it is guaranteed that the return value of CrudRepository.save() will never be null. However, what about the older versions, specifically 1.13.18.RELEASE?

If the older version does guarantee return of non-null values then it renders the following piece of code useless, right?

        Entity savedEntity = someRepository.save(entity);
        if (savedEntity == null) {
            // throw some checked exception stating that the save failed..
        }

And if the older version doesn't guarantee return of a non-null value, then what scenario would lead to the return of a null value?

Update: Since my question is pertaining to the implementation of CrudRepository, it is important to point out that I am using 1.11.18.RELEASE of spring-data-jpa. I want to know about the behaviour of save function for this version.

like image 918
WillyWonka Avatar asked Sep 09 '26 19:09

WillyWonka


1 Answers

same issue here. Even though it should never return null, in my project I get a null value (silent failure) when I update an existing entity. If I create a new entity it works. I tried also implementing the Persistable interface, but still the same issue. I am using Spring Data + R2DBC + Java 15.

like image 108
Davide Pugliese Avatar answered Sep 11 '26 09:09

Davide Pugliese



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!