美好的一天,我有一个@Formula的字段,就像这样:
@Formula("(select isnull((select case when( DATEADD(\"MONTH\", -6 , GETDATE())> s.activation_date or d.device_first_data_send is not null ) then '1' else '0' end from telematic_device d join sim_card s on s.id = d.sim_card_id where d.id = id),0))")
这是JHipster app,所以春天&春天传呼&冬眠。 我们也使用MSSQL。 因此在分页期间,此请求变为
(SELECT inner_query.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__ FROM ( select TOP(@P0) telematicd0_.id as id1_12_, telematicd0_.billing_state as billing_2_12_, telematicd0_.consumer_id as consumer9_12_, telematicd0_.device_first_data_send as device_f3_12_, telematicd0_.i_mei as i_mei4_12_, telematicd0_.manufacturer as manufact5_12_, telematicd0_.product_name as product_6_12_, telematicd0_.shippment_date as shippmen7_12_, telematicd0_.sim_card_id as sim_car10_12_, telematicd0_.status as status8_12_, telematicd0_.tenant_id as tenant_11_12_, (select isnull((select case when( DATEADD("MONTH", -6 as page0_, GETDATE())> s.activation_date or d.device_first_data_send is not null ) then '1' else '0' end from telematic_device d join sim_card s on s.id = d.sim_card_id where d.id = telematicd0_.id),0)) as formula0_ from telematic_device telematicd0_ order by telematicd0_.id asc ) inner_query ) SELECT id1_12_, billing_2_12_, consumer9_12_, device_f3_12_, i_mei4_12_, manufact5_12_, product_6_12_, shippmen7_12_, sim_car10_12_, status8_12_, tenant_11_12_, DATEADD("MONTH", page0_, formula0_ FROM query WHERE __hibernate_row_nr__ >= @P1 AND __hibernate_row_nr__ < @P2
但是有一个问题:我们在一个函数内部将这个作为page0_来获取,这显然是一个问题和/或hibernate本身的一个bug。
( DATEADD("MONTH", -6 as page0_, GETDATE())> s.activation_date
所以问题是 - 之前有没有人看到这个并且有办法解决这个问题吗?
提前谢谢。