JPA 实体必须使用哪些 lombok 注释,我正在考虑删除和
@AllArgsConstructor
。我应该删除 @Data
因为我正在覆盖
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
我需要@Data吗?
@Data: This generates equals, hashCode, and toString methods, which can cause issues with JPA. It's better to avoid this annotation for entities and define these methods manually or use other Lombok annotations selectively.
实体定义
@Slf4j
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@SuperBuilder
@Entity
@Table(name = "foos")
public class Foo extends Bar {
..
}