Property元素中的formula容許對象屬性包含導出值,好比sum、average、max等的結果。如:java
<property name="averagePrice" formula="(select avg(pc.price) from PriceCatalogue pc, SelectedItems si where si.priceRefID=pc.priceID)"/> web
此外,formula還能夠基於當前記錄的特定屬性值從另外一個表檢索值。例如:spring
<property name="currencyName" formula="(select cur.name from currency cur where cur.id= currencyID)"/> sql
代碼數據庫
<property name="notIncomeFee" type="java.lang.Double" formula="(case when fee_authorize is null then 0 else fee_authorize end)-(select (case when sum(i.fee_sum) is null then 0 else sum(i.fee_sum) end) from S_PROJECT_INCOME i where i.project_id=id and i.CHECK_STATUS_ID=2)">spa
問題:
1,org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type setter of
沒用別名,會出現這個錯誤,添個別名就行了
2,若是我要用obj.getSchNum()獲得想要的值,該對象(obj)必須是hibernate取得的對象,
3,若是要傳入參數,如上面那個,currencyID是該對象的屬性,它的值也是有hibernate操做當前對象時,把該屬性對應的值自動傳入進去.hibernate