简体   繁体   中英

referencing table names (not aliases) in hints

I'm using eclipse link as JPA implementation. I have a named Query like this:

@NamedQuery(name = "QueryName",
            query = "SELECT c FROM Customer c, AccountingUnit au where c.contract.state = :state AND ...")

The resulting SQL query will actually query over 4 tables that get table aliases t0, t1, t2, t3 similar like this:

SELECT ... FROM CUSTOMER t0, ACCOUNTING_UNIT t1, CUSTOMER_CONTRACT t2, ...

and now I want to add an Oracle Hint which works when I say:

query.setHint("eclipselink.sql.hint" , "/*+ USE_NL(t0 t2) */");

but I would prefer to write it like this:

query.setHint("eclipselink.sql.hint" , "/*+ USE_NL(Customer Customer_Contract) */");

Is there any way to do this?

IMHO when using aliases Oracle will only use hint when it contains those aliases.

I doubt that EclipseLink even tries to distinguish between various hints. The word in the hint can also be an indexname or some magic constant.

The best would be to check EclipseLink source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM