hibernate中@Transient的运用
hibernate中@Transient的使用
项目中可能有许多实体的需要辅助的属性和方法辅助,hibernate中实体bean中所有的非static非@Transient那么必须使用@Transient注解的属性都可以被持久化,除非你将其注解为@Transient。
所有没有定义注解的属性相等于@Basic。
@Transient
public BigDecimal getTotalServicePrice() {
BigDecimal total = new BigDecimal(0);
// 总修正费用
total = total.add(getTotalFixPrice());
// 总送票费用
BigDecimal df = getDeliveryInfo().getDeliveryFare();
if (df != null)
total = total.add(getDeliveryInfo().getDeliveryFare());
// 总的卖价格调整
total = total.add(priceFix);
return total;
}