openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miłosz Tylenda <mtyle...@o2.pl>
Subject Re: Using Oracle hint generates SQL syntax error
Date Fri, 09 Sep 2011 13:49:40 GMT
Hi,

openjpa.hint.OptimizeResultCount is supported only with DB2. Have a look at Oracle documentation
to see if they have a hint with similar functionality. If yes, use it like

query.setHint("openjpa.hint.OracleSelectHint", "[HINT TEXT GOES HERE]");

What openjpa.hint.OracleSelectHint does is basically pasting the hint text literally between
"SELECT" and column list.

Regards,
Milosz


Dnia 9 września 2011 11:37 "M. Walter" <marc.walter@sbb.ch> napisał(a):

> I used an Oracle query hint as described in the OpenJPA documentation:
> 
> final Query query = em.createQuery("SELECT b FROM Bp b");
> query.setHint("openjpa.hint.OracleSelectHint", new Integer(2000));
> final List<Bp> result = query.getResultList();
> 
> Executing this query fails with
> "org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00923: FROM keyword
> not found where expected (java.sql.SQLSyntaxErrorException: ORA-00923: FROM
> keyword not found where expected)".
> This is the generated query: SELECT 2000 t0.ID [some other attributes left
> out here] FROM BP t0
> Why is OpenJPA generating wrong SQL statements?
> 
> I also tried to set the query hint in a named query:
> <named-query name="FIND_ALL_BP">
>     <query></query>
>     <hint name="openjpa.hint.OptimizeResultCount" value="2000"/>
> </named-query>
> 
> final Query namedQuery =
> em.createNamedQuery(MyQueryNames.FIND_ALL_BP.name());
> final List<Bp> result = namedQuery.getResultList();
> 
> This query was executed but it did not show any hint. It simply was "SELECT
> b FROM Bp b" so I guess the hint was just ignored because the SELECT did not
> perform any faster.
> 
> Any suggestions on how to successfully use query hints?
> 
> I'm using Oracle 11g and OpenJPA 1.2.3.
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/Using-Oracle-hint-generates-SQL-syntax-error-tp6775413p6775413.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Mime
View raw message