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