在hibernate 中通过写一个sql 语句封装一个字段

<property name="yellowday" type="java.lang.Integer" formula="(select datediff(day,t.filldate,
   (select top  1 (t.year+'-'+t.month+'-'+t.day) from t_sys_holiday t
   where t.year+'-'+t.month+'-'+t.day>=
   (select  dateadd(day,(select t.yellowday  from t_pz_db t  where t.rendertype='S' and t.headtype='1'),r.enddate)
   from t_zn_task_reduce r where r.id=id)
   and t.holiday='0')) from t_zn_task_schedule t  where t.momentid=id)">      
        </property>     
            
  <property name="redday" type="java.lang.Integer" formula="(select datediff(day,t.filldate,
   (select top  1 (t.year+'-'+t.month+'-'+t.day) from t_sys_holiday t
   where t.year+'-'+t.month+'-'+t.day>=
   (select  dateadd(day,(select t.redday from t_pz_db t  where t.rendertype='S' and t.headtype='1'),r.enddate)
   from t_zn_task_reduce r where r.id=id)
   and t.holiday='0')) from t_zn_task_schedule t  where t.momentid=id)">            
   </property>           
       

你可能感兴趣的:(Hibernate)