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.
According to implementation, it will always return a value or throw an exception
Update the implementation is for
1.11.18.RELEASE
. From GitHub repository