Skip to content

[Spring] JPA 변경감지 관련 질문 #185

Answered by PFCJeong
DoohyunHwang97 asked this question in Q&A
Discussion options

You must be logged in to vote

두현님 안녕하세요~

엔티티 프로퍼티를 var로 바꿔주셔도 됩니다.

setter를 정의하는게 어색하긴 해요. 조금 더 자세히 말씀드리면,,

아래 코틀린 코드가 사실은

@Entity(name = "playlists")
class PlaylistEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0L,
    var viewCnt: Int,
)

자바코드로는 이렇습니다.

public class PlaylistEntity {
   @Id
   @GeneratedValue(
      strategy = GenerationType.IDENTITY
   )
   private final long id;
   private int viewCnt;

   public long getId() {
      return this.id;
   }

   public int getViewCnt() {
      return this.viewCnt;
   }

   public void setViewCnt(int var1) {
      this.viewCnt = var1;
   }

   public PlaylistEntity(long id, int viewCnt) {
      this.id = id;
      this.viewCnt = v…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DoohyunHwang97
Comment options

Answer selected by DoohyunHwang97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Spring Spring 관련 내용
2 participants