Problem in using SQL Keyword in JPQL [message #894815] |
Tue, 10 July 2012 15:59 |
Igor B Messages: 9 Registered: July 2012 |
Junior Member |
|
|
Hi,
I try to use the following Named Query;
@NamedQuery (name="findbyNr",
query="SELECT o FROM MyBean o WHERE o.Nr= :Nr ORDER BY o.year DESC SQL('FETCH FIRST 100 ROWS ONLY')"
When I test my code I get the following exception:
Exception Description: Syntax error parsing [SELECT o FROM MyBean o WHERE o.Nr = :Nr AND ORDER BY o.year DESC SQL('FETCH FIRST 100 ROWS ONLY')].
[java] [124, 125] The ORDER BY clause has 'o.year DESC ' and 'SQL('FETCH FIRST 100 ROWS ONLY')' that are not separated by a comma.
[java] at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:616)
[java] at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:596)
[java] at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:186)
If I place a comma between DESC and SQL, so my DB2 driver complains like:
16:58:40 [SELECT - 0 row(s), 0.000 secs] [Error Code: -104, SQL State: 42601] DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=FIRST;;ASC DESC, DRIVER=3.57.82
So how can I solve my problem? Or is it a bug?
Any input welcome.
best regards,
Igor
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03640 seconds