有没有办法从 @EqualsAndHashCode 中排除除 @Id 列之外的所有字段

Is there a way to exclude all the fields from @EqualsAndHashCode other than the @Id column

在我的 domain/Pojo 中,我想排除除 @EmbeddedId@Id 之外的所有字段。

排除它们的一种方法是在所有字段上使用@Exclude,我想知道是否还有另一种简短方法?

例如

@Entity(name = "TestView")
@Table(name = "Test_View")
@Data
@EqualsAndHashCode(callSuper = false)
public class TestView implements Serializable {

    private static final long serialVersionUID = -9181710663858694093L;

    @Id
    @Column(name = "PRCL_SEQ_NUM")
    private Integer prclSeqNum;

    @Exclude
    @Column(name = "CMPS_TAKE_ACQ_VAL")
    private String takeAcq;

    @Exclude
    @Column(name = "REMND_ACQ_IND")
    private String remndAcqInd;
}

在 class 上使用 @EqualsAndHashCode(onlyExplicitlyIncluded = true),然后在要包含的字段上使用 @EqualsAndHashCode.Include