Код: Выделить всё
@Query(value = """
INSERT INTO users(id, customerId, locale) VALUES (:id, :customerId, :title, :locale)
""", nativeQuery = true)
void create(@Param("id") Long id,
@Param("customerId") String customerId,
@Param("title") String title,
@Param("locale") String locale,
.........
public enum Title {
CEO
}
...
public class Profile {
private Title title;
// getter/ setter
}
profileRepository.create(
profile.getId(),
profile.getCustomerId(),
Optional.of(profile.getTitle().name()).orElse(null)
profile.getLocale())
Код: Выделить всё
java.lang.NullPointerException: Cannot invoke "com.entity.Title.name()" because the return value of "com.entity.Profile.getTitle()" is null
Подробнее здесь: https://stackoverflow.com/questions/791 ... -of-is-nul