在已经使用JPA和spring数据的项目中使用属性版本的业务逻辑时,如何处理有关版本的问题?最好的方法是为jpa类注释一个称为versionJPA的属性,然后导入javax.persistence.Version或使用import org.springframework.data.annotation.Version?
导入org.springframework.data.annotation.Version;
import javax.persistence.Version;
@Table(name = "BUSINESS")
@Getter
@Setter
@Slf4j
@Entity
public class Business extends Auditable implements Cloneable{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BUSINESS")
@Column(name = "BUSINESS_ID")
private Integer id;
@Version
private Long versionJPA;
private static final long serialVersionUID = 1L;
@Column(name = "VERSION")
@JsonProperty("Version")
private String version;
}