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 )
测试 按照方法名字顺序执行