I have some entity AuditEntity. I need get eventType value by entityId.
How to make the dealState field in AuditEntity always be zero when the findFirstByEntityIdOrderByCreatedTimeDesc method is executed, regardless of the value of this field in the database?
How correct would it be to use @Lazy (import org.springframework.context.annotation.Lazy) if the dealState field is not the key for another table?
@Entity
@Table(name = "audit")
class AuditEntity(
@Id
override var id: Long? = null,
@Basic
@Column(name = "entity_id")
val entityId: Long,
@Basic
@Enumerated(EnumType.STRING)
@Column(name = "event_type")
val eventType: AuditEventType,
@Type(type = "jsonb")
@Column(name = "deal_state", columnDefinition = "jsonb")
val dealState: Deal? = null
) : BaseEntity<Long>()
@Repository
interface AuditRepository : JpaRepository<AuditEntity, Long> {
fun findFirstByEntityIdOrderByCreatedTimeDesc(entityId: Long): AuditEntity?
}