Does a query occur through dirty checking even if the same value is inserted into the corresponding column?

10 Views Asked by At

I'm configuring an entity update method, and I'm curious what the result will be if I put the same value in the same column as before and perform dirty checking.

public class Member extends BaseEntity {

    @Id
    @Column(name = "member_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(unique = true, nullable = false)
    private String email;

    @Column(nullable = false)
    private String password;

    @Column(unique = true, nullable = false)
    private String username;

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private MBTI mbti;

    @Column
    private Boolean isDeleted;

    @Column
    private String statusMessage;

    @Column
    private String avatar;

    public static Member toEntity(MemberRequestDto.signup requestDto) {
        return Member.builder()
            .email(requestDto.getEmail())
            .password(requestDto.getPassword())
            .username(requestDto.getUsername())
            .mbti(requestDto.getMbti())
            .statusMessage(requestDto.getStatusMessage())
            .isDeleted(false)
            .build();
    }

    public void update(MemberRequestDto.update requestDto) {
        this.password = requestDto.getPassword();
        this.username = requestDto.getUsername();
        this.mbti = requestDto.getMbti();
        this.statusMessage = requestDto.getStatusMessage();
    }

    public void uploadAvatar(String url) {
        this.avatar = url;
    }
}

In update method, Does the query occur if the column value of requestdto is already the same as the entity?

0

There are 0 best solutions below