我有一些实体类,我有一个问题,因为我想在我的脑海中清除它。万一 @ManyToOne
例如,我插入的关系 @JoinColumn(name = "cardHolderId")
,我要删除原语吗 private Long cardHolderId
? 因为我进行了一次讨论,一个程序员向我解释说我可以避免声明。但是如果我避免使用它,我就不能在服务之类的测试用例中使用它。
@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "card")
public class Card {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "code")
private String code;
@Column(name = "number")
private String number;
@Column(name = "issueDate")
private Date issueDate;
@Column(name = "expireDate")
private Date expireDate;
@Column(name = "elasticDate")
private Date elasticDate;
@Column(name = "pin")
private Long pin;
@Column(name = "isValid")
private Boolean isValid;
@Column(name = "isUsed")
private Boolean isUsed;
@Column(name = "isPin")
private Boolean isPin;
@Column(name = "cardCategoryId")
private Long cardCategoryId;
@Column(name = "hasNumberOfVisits")
private Boolean hasNumberOfVisits;
@Column(name = "numberOfVisits")
private Long numberOfVisits;
@Column(name = "isBlackListed")
private Boolean isBlackListed;
@Column(name = "cardHolderId")
private Long cardHolderId;
//Check Relationships
@ManyToOne
@JoinColumn(name = "cardCategoryId")
private CardCategory cardCategory;
@ManyToOne
@JoinColumn(name = "cardHolderId")
private CardHolder cardHolder;
@Column(name = "companyGroupId")
private Long companyGroupId;
@ManyToOne
@JoinColumn(name = "companyGroupId")
private CompanyGroup companyGroup;
@OneToMany(mappedBy = "card")
private List<AccessControlSubject> accessControlSubjects = new ArrayList<>();
@OneToMany(mappedBy = "card")
private List<Card2Role> card2Roles = new ArrayList<>();
@ManyToOne
@JoinColumn(name = "cardHistoryId")
private CardHistory cardHistory;
@OneToMany(mappedBy = "vehicleCard")
private List<Vehicle> vehicles = new ArrayList<>();
@ManyToOne
@JoinColumn(name = "sharedCardId")
private PatrolSharedCard sharedCard;
@ManyToOne
@JoinColumn(name = "productionWorkId")
private PrdWork productionWork;
@ManyToOne
@JoinColumn(name = "productionWorkHitsId")
private PrdWorkHits productionWorkHits;
@OneToMany(mappedBy = "card")
private List<VisitorCardHistory> visitorCardHistories = new ArrayList<>();
1条答案
按热度按时间9udxz4iz1#
您可以将其删除并使用引用实体的id: