如何将具有union的sql-query转换为queryDSL

时间:2017-01-05 10:52:13

标签: sql querydsl

我正在尝试将以下查询转换为Query-DSL。 我不知道如何从中填充实际结果集。如何在spring&中编写以下查询querydsl。请帮忙。我是QueryDSL的新手。

 SELECT * FROM
--First part of union
          (SELECT V.ID AS VID,
            V.MODEL,
            V.VIN,
            V.EXTERIOR_COLOR,
            V.LICENSE_PLATE,
            V.CURRENT_LOCATION,
            V.NOTES,
            L.DATE_OUT  AS DAYOUT,
            L.DATE_IN   AS DAYIN,
            NULL  AS HOLD,
            ''   AS REASONS,
            NULL AS ADATE,
           FROM PFIS_VEHICLE_DETAILS V,
            PFIS_CONTACT C,
            PFIS_VEHICLE_CONTACT_LOAN L
          WHERE C.ID          =L.CONTACT_ID
          AND V.ID            =L.VEHICLE_ID
          AND L.LOAN_TYPE_ID IN (1,5)
         UNION
    -- Second part of the union fetch from data for status-Id=4
          SELECT V.ID AS VID,
            V.MODEL,
            V.VIN,
            V.EXTERIOR_COLOR,
            V.LICENSE_PLATE,
            V.CURRENT_LOCATION,
            V.NOTES,
            NULL               AS DAYOUT,
            NULL               AS DAYIN ,
            S.ON_HOLD_TILL     AS HOLD,
            S.REASONS_FOR_HOLD AS REASONS,
            S.ANTICIPATED_DATE AS ADATE,
           FROM PFIS_VEHICLE_DETAILS V,
            PFIS_VEHICLE_DETAIL_STATUS S
          WHERE V.ID     =S.VEHICLE_ID
          AND S.STATUS_ID=4

        )

0 个答案:

没有答案