4.Project Trouble Shooting : BaseTimeEntity _CreatedAt, ModifiedAt aren't saved properly

#Foreword

To be honest, I've never tried to set up the initial structure before. Whenever I develop a specific domain, Entity's timestamp is automatically saved in DB. In other words, I didn't recognize what the problem is. While I am setting up the Spring project initial structure, I've found problems that Entity's timestamp isn't saved properly in the database. Solution might be very simple, but it would be helpful for someone who didn't know this like me. Problem isn't a problem if I know it well, so I am documenting troubleshooting logging for my future use and organizing my thoughts.

#Problem : created_at, modified_at aren't saved in db properly

Even though Member Entity extends BaseTimeEntity, createdAt and modifiedAt aren't saved in Database, Why?

#Why is BaseTimeEntity needed for Entity Class?

: This code automatically adds createdAt and updatedAt timestamps to the entity in the database. This is beneficial for maintenance as it succinctly explains the functionality, helping developers quickly grasp the purpose of the class. See below.

#BaseTimeEntity Setup + Example use

: Like below, I extend all of entities to BaseTimeEntity.

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseTimeEntity {

    @CreatedDate
    protected LocalDateTime createdAt;

    @LastModifiedDate
    protected LocalDateTime updatedAt;

}

#Solution - Add JpaAuditorConfig

@Configuration
@EnableJpaAuditing
public class JpaAuditorConfig {
// Without this, We can't save createdAt, modifiedAt in database.
}

Nicely done :