使用JPA查询在当前日期中添加天/日期

时间:2019-04-17 12:42:49

标签: java mysql hibernate spring-boot jpa

我想使用JPA在当前日期再增加14天。

SELECT 
    b.id as bookingID, b.account_id, b.campaign_id, 
    DATE_FORMAT(DATE_ADD(c.created, INTERVAL 14 DAY), '%m/%d/%Y') as campaignCreatedDate,
    DATE_FORMAT(c.program_start_date, '%m/%d/%Y')  as campaignPlannedStartDate
FROM
    booking b,
    account a,
    campaign c
WHERE
     b.stage IS NULL AND b.is_active = 1 AND a.is_active = 1 AND  c.is_active = 1 AND b.campaign_id = c.id AND  b.account_id = a.id;

 i am trying to covert above sql query into JPA like     

 @Query("select new com.xxx.campaign.model.TestRequest("
        + " b.id as bookingID, b.account.id,  accountOwner, "
        + " b.campaign.id, 
        + " c.created as campaignCreatedDate, "
        + " b.campaign.programStartDate as campaignPlannedStartDate) "
        + " FROM "
        + " Booking b "
        + " join b.account a "
        + " join b.campaign c "
        + " WHERE "
        + " b.stage IS NULL AND b.isActive = 1 AND b.account.isActive = 1 AND  b.campaign.isActive = 1")
public List<TestRequest> getTestDetails();

我的SQL查询在当前日期增加了14天     例如我当前的日期是2019/01/01     我将在2019年1月15日获得输出     我的问题是,如何通过JPA查询添加14天?

0 个答案:

没有答案