I\'ve implemented in my spring repository interface:
@Query(\"SELECT max(ch.id) FROM MyEntity ch\") Long getMaxId();
It works correctly if db i
You can use coalesce like :
coalesce
@Query("SELECT coalesce(max(ch.id), 0) FROM MyEntity ch") Long getMaxId();
If there are no data it will return 0 instead of null.