我有大约 300 个 JPA 实体,其中的 getter 使用持久性注释进行注释。我想找到一种方法将所有此类注释移至属性并删除所有 getter 和 setter。我手动为这些课程中的大约 100 个进行了此操作,但这是非常耗时且令人麻木的工作。
我正在研究像Spoon这样的源代码转换工具,但仍然不确定它能否完成我需要它做的事情。
更具体地说,如何转换此代码:
@Entity
@Table(name = "crm_ticket")
public class CrmTicket implements Serializable {
private static final long serialVersionUID = -902718555957517699L;
private CrmAccount crmAccount;
private ItsType subType;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "account")
public CrmAccount getCrmAccount() {
return crmAccount;
}
public void setCrmAccount(CrmAccount crmAccount) {
this.crmAccount = crmAccount;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sub_type")
public ItsType getSubType() {
return subType;
}
public void setSubType(ItsType type) {
this.subType = type;
}
}
对此:
@Entity
@Table(name = "crm_ticket")
@Data
public class CrmTicket implements Serializable {
private static final long serialVersionUID = -902718555957517699L;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "account")
private CrmAccount crmAccount;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sub_type")
private ItsType subType;
}