I have a JPA entity with the following fields:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "modified_by_user_id")
private User modifiedByUser;
@Convert(converter = LocalDatetimeAttributeConverter.class)
private LocalDateTime modifiedDatetime;
"modified_by_user_id" and "modified_datetime" columns have a default value in the DB. If I do a manual insert into, the columns will get their default values without being explicitly specified.
However, while saving the entity with Spring Data JPA, the default values is not being calculated and it shows null in the DB
Contributor contributor = new Contributor();
contributor.setName("a");
contributorRepository.save(contributor);
Why is not the default values being calculated when I save the entity with Spring Data JPA?