Skip to content

Commit

Permalink
Update default value strategy in BaseEntity class
Browse files Browse the repository at this point in the history
  • Loading branch information
geminiKim committed Aug 19, 2024
1 parent bc96714 commit c671e73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.dodn.springboot.storage.db.core

import jakarta.persistence.Column
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
Expand All @@ -13,14 +12,11 @@ import java.time.LocalDateTime
abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long? = null
val id: Long = 0

@CreationTimestamp
@Column(updatable = false)
val createdAt: LocalDateTime? = null
val createdAt: LocalDateTime = LocalDateTime.MIN

@UpdateTimestamp
@Column
var updatedAt: LocalDateTime? = null
protected set
val updatedAt: LocalDateTime = LocalDateTime.MIN
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExampleRepositoryIT(
val saved = exampleRepository.save(ExampleEntity("SPRING_BOOT"))
assertThat(saved.exampleColumn).isEqualTo("SPRING_BOOT")

val found = exampleRepository.findById(saved.id!!).get()
val found = exampleRepository.findById(saved.id).get()
assertThat(found.exampleColumn).isEqualTo("SPRING_BOOT")
}
}

0 comments on commit c671e73

Please sign in to comment.