Cannot set any value LocalDateTime in Entity of Spring Boot Example

I have a problem to set LocalDateTime.now to the entity of Spring Boot Example Here is the entity shown below
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "PARK")
public class ParkEntity extends BaseEntity {

...

@Column(name = "CHECK_IN")
private LocalDateTime checkIn;


....
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "PARK")
public class ParkEntity extends BaseEntity {

...

@Column(name = "CHECK_IN")
private LocalDateTime checkIn;


....
}
Here is the method shown below
private Park parkMethod(....) {
ParkEntity parkEntity = ....
parkEntity.setCheckIn(LocalDateTime.now());
ParkEntity savedPark = parkRepository.save(parkEntity);
return parkEntityToParkMapper.map(savedPark);
}
private Park parkMethod(....) {
ParkEntity parkEntity = ....
parkEntity.setCheckIn(LocalDateTime.now());
ParkEntity savedPark = parkRepository.save(parkEntity);
return parkEntityToParkMapper.map(savedPark);
}
I get null value in checkIn of savedPark . I have to manually set the LocalDateTime.now() instead of using @Builder.Default How can I do that?
7 Replies
JavaBot
JavaBot9mo ago
This post has been reserved for your question.
Hey @direct_x_34! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
direct_x_34
direct_x_34OP9mo ago
I have also @PrePersist method in BaseEntity and I cannot use ParkEntity. I have also other entities extending from BaseEntity. How can I do that? @*
dan1st
dan1st9mo ago
I think Lombok's @Builder.Default is just for builders Do what? Also why did you ping the wildcard/top role?
tjoener
tjoener9mo ago
Why does everybody keep using lombok in entities...
Kyo-chan
Kyo-chan9mo ago
Why does everybody keep using lombok and then not have Java work the same as it does with everyone
tjoener
tjoener9mo ago
I mean, you can, but the blanket statements people add is just bad API design
JavaBot
JavaBot9mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server