table_supplier_bills - bill_id, supplier_id, date
型號
@Entity
@Table(name = "table_supplier_bills")
public class SupplierBill {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="bill_id")
private Integer billId;
@Column(name="supplier_id")
private Integer supplierId;
@Column(name="date")
private String date;
@Column(name="bill_amount")
@Transient
private BigDecimal billAmount;
@Column(name="paid_amount")
@Transient
private BigDecimal paidAmount;
public SupplierBill() {
super();
}
public Integer getBillId() {
return billId;
}
public void setBillId(Integer billId) {
this.billId = billId;
}
public Integer getSupplierId() {
return supplierId;
}
public void setSupplierId(Integer supplierId) {
this.supplierId = supplierId;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public BigDecimal getBillAmount() {
return billAmount;
}
public void setBillAmount(BigDecimal billAmount) {
this.billAmount = billAmount;
}
public BigDecimal getPaidAmount() {
return paidAmount;
}
public void setPaidAmount(BigDecimal paidAmount) {
this.paidAmount = paidAmount;
}
]
庫
@Query(value = "SELECT SB.bill_id, SB.date, SB.supplier_id, SUM(SBD.quantity * SBD.rate) as bill_amount, COALESCE((SELECT SUM(SBPD.payment_amount) FROM table_supplier_bill_payment_details SBPD WHERE SBD.bill_id = SBPD.bill_id),0.00) as paid_amount from table_supplier_bills SB INNER JOIN table_supplier_bill_details SBD ON SB.bill_id = SBD.bill_id WHERE SB.supplier_id = ?1 group by SBD.bill_id ORDER BY SB.bill_id DESC" , nativeQuery = true)
List<SupplierBill> getSupplierBills(Integer sid);
當我打電話上面的方法,我沒有得到bill_amount和從服務中支付金額。如果我刪除@Transient它的工作原理,但後來我因爲抱怨未知列bill_amount和paid_amount我不能夠調用
supplierBillRepository.save(supplierBill);
。
我需要做什麼改變,所以它適用於兩種方法?
你的意思是不持久(標有'@ Transient')這些領域?你很驚訝它沒有在數據存儲中找到它們? –