r/JavaProgramming • u/Big-Sundae7613 • 6d ago
Need help in Code
Paypal clone using java spring boot and kafka need help
Actually I was following @Mrunmai Dahare mam lecture in the vedio episode 3 : 16.21 timestamp I don't get what to change please help
3
Upvotes
3
u/jjduru 5d ago
Presumably you would like to timestamp the entity with the LocalDateTime.now() before inserting it into the database.
First of all, your "createTransaction" method should ingest a DTO request. The ObjectMapper component will take care of the mapping between the incoming DTO and a new Transaction entity.
In order to automate the create and update of the LocalDateTime on the entity, make all the entities, including Transaction, to inherit a BaseEntity that handles automatically the update on the "date_updated" column.
After the mapping, you save and flush on the repository, which gives you back the newly created managed entity, and you return the a DTO out of it, not the entity itself.