with querydsl, am i able to execute the following oracle sql (with hint and select from dual)?

638 views
Skip to first unread message

Zhao Liang

unread,
May 18, 2016, 2:41:27 AM5/18/16
to Querydsl
I am using querydsl for my queries in oracle, so far is good until i found some native sql query as follow, am i able to do that in querydsl?
There are two problem for me
#1, how can i convert "select 1 from dual" in querydsl
#2, how can i take the oracle hint "/*+ INDEX(abs UKACCTBILLSETTINGS_ACCTID) */"?

Thanks 

SELECT 1
        FROM dual
        WHERE EXISTS (
            SELECT /*+ INDEX(abs UKACCTBILLSETTINGS_ACCTID) */ 1 FROM acctbillsettings abs
            WHERE abs.retailBilling IN (:nonNoneRetailInvoiceTypes)
            AND abs.acctid IN (SELECT acctid FROM accts WHERE operatorid = :operatorId and LOWER(accttype) IN (:nonSubscriberAcctTypes))
        )

Ruben Dijkstra

unread,
May 18, 2016, 3:39:36 AM5/18/16
to Querydsl
Hi,

On Wednesday, 18 May 2016 08:41:27 UTC+2, Zhao Liang wrote:
I am using querydsl for my queries in oracle, so far is good until i found some native sql query as follow, am i able to do that in querydsl?
There are two problem for me
#1, how can i convert "select 1 from dual" in querydsl
FROM DUAL is added if you didn't specify the .from() part.

 
#2, how can i take the oracle hint "/*+ INDEX(abs UKACCTBILLSETTINGS_ACCTID) */"?

That should be doable with query.addFlag(QueryFlag.Position.AFTER_SELECT, "the hint text")
Do mind the proper Java escaping, the sql comment must still be applied, but then it will be serialized into the query like you wanted.
I can't test the query though, I don't have an Oracle database.

Best regards,

Ruben Dijkstra
Reply all
Reply to author
Forward
0 new messages