我看到2018年有一个类似的问题: Mapstruct to update value without overwriting,但没有解决这个问题的例子。
因此,我不知道如何解决它。
我正在使用Lombok和MapStruct
UserEntity代表数据库中的表
@Getter
@Setter
@Entity
@Table(name = "users")
public class UserEntity implements Serializable {
private static final long serialVersionUID = -3549451006888843499L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) // this specifies that the id will be auto-incremented by the database
private Long id;
@Column( nullable = false)
private String userId;
@Column( nullable = false, length = 50)
private String firstName;
@Column( nullable = false, length = 50)
private String lastName; …Run Code Online (Sandbox Code Playgroud)