1.@jsaonIgnoreProperties
忽略類中不需要的字段
@JsonIgnoreProperties(value = {
"available",
"driverVehicleBindings"
})
public class User extends BaseEntity{
}
2.@Convert
jpa中實體屬性類型轉換器
參考鏈接:https://blog.csdn.net/hong0220/article/details/50909211
3.@Embeddable
一個實體類在多個不同實體類使用,本身不需要獨立生成數據庫表
public class User{
@Id
@GeneratedValue(generator = "user-uuid")
@Column(name="user_id")
private String userId;
//映射Station的stationId
@Embedded
@AttributeOverrides({
@AttributeOverride(name="stationId",
column=@Column(name="start_station_id"))
})
private Station original;
//將Price中所有屬性都映射
private Price price;
}
@Embeddable
@Data
public class Station {
private String stationId;
@Transient
private String name;
@Transient
private String type;
}
@Embeddable
@Data
public class Price {
/**
* 應付價格
*/
private double price;
/**
* 實付價格
*/
private double actualPrice;
/**
* 價格類型
*/
private String priceType;
}
4.@FixMethodOrder(MethodSorters.NAME_ASCENDING )
測試 按照方法名字順序執行