I ran into a problem last week when trying to deploy our application on Weblogic 12c. (12.1.1). Until now our application was running on weblogic 10.3.4.
Several of our JPA queries do not compile/execute anymore due to the new eclipselink version : 2.3.1 embedded in weblogic 12.1.1.
On weblogic 10.3.4 the JPA queries work fine (eclipselink version 2.1.3). On 12c, with eclipselink version 2.3.1, we get a ORA-0904 error on several queries. Eclipselink 2.3.1 does not compile the query into a correct native SQL query (same problem as http://www-01.ibm.com/support/docview.wss?uid=swg24022303).
SELECT DISTINCT cla FROM Classe cla, IN (cla.aet.formation.MVfos) mvfo
WHERE cla.ans = :ansCode
AND cla.lycee.id = :lyceeid
AND mvfo.ans = :ansCode AND cla.aet.niveauEtudes IN :nEtudes
// Is a child of me selected?
AND (EXISTS (SELECT mvfo2.id FROM MVfo mvfo2 WHERE mvfo.MFor.id = mvfo2.MFor.formationLie.id AND mvfo2.id IN :mvfoids)
// Is the parent of myself selected?
OR EXISTS(SELECT mvfo3.id FROM MVfo mvfo3 WHERE mvfo.MFor.formationLie.id = mvfo3.MFor.id AND mvfo3.id IN :mvfoids)
// Is a "brother" of myself selected (and it's not me)?
OR EXISTS(SELECT mvfo4.id FROM MVfo mvfo4 WHERE mvfo.MFor.formationLie.id = mvfo4.MFor.formationLie.id AND mvfo4.id IN :mvfoids AND mvfo.id <> mvfo4.id))
ORDER BY cla.code
The resulting SQL :
SELECT DISTINCT t0.ID, t0.ALIAS, t0.ANS, t0.CLOTURE_P1, t0.CLOTURE_P1_NOTES, t0.CLOTURE_P1_REGENT, t0.CLOTURE_P2, t0.CLOTURE_P2_NOTES, t0.CLOTURE_P2_REGENT, t0.CLOTURE_P3, t0.CLOTURE_P3_NOTES, t0.CLOTURE_P3_REGENT, t0.CODE, t0.CONSEIL_P1, t0.CONSEIL_P2, t0.CONSEIL_P3, t0.DEBUT_SAISIE_P1, t0.DEBUT_SAISIE_P2, t0.DEBUT_SAISIE_P3, t0.FIN_SAISIE_P1, t0.FIN_SAISIE_P2, t0.FIN_SAISIE_P3, t0.FORMATION_NB_HEURES, t0.FORMATION_TAUX_PRESENCE, t0.FORMATION_TITRE, t0.LECONS_P1, t0.LECONS_P2, t0.LECONS_P3, t0.MAX_ELEVES, t0.MIN_ELEVES, t0.TRI1, t0.TRI2, t0.TRI3, t0.TRI4, t0.TYPE_HORAIRE, t0.AET_ID, t0.LYC_ID, t0.ENS_ID
FROM AET t3, M_FOR t2, M_VFO t1, CLA t0
WHERE ((((((t0.ANS = ?) AND (t0.LYC_ID = ?)) AND (t1.ANS = ?)) AND (t3.NIVEAU_ETUDES IN (?,?,?,?)))
AND ((EXISTS (SELECT ? FROM M_FOR t7, M_FOR t6, M_FOR t5, M_VFO t4
WHERE (((t5.ID = t6.ID) AND (t4.ID IN (?))) AND (((t7.ID = t4.M_FOR_ID) AND (t5.ID = t1.M_FOR_ID)) AND (t6.ID = t7.M_FOR_ID_LIE))))
OR EXISTS (SELECT ? FROM M_FOR t10, M_FOR t9, M_VFO t8
WHERE (((t9.ID = t10.ID) AND (t8.ID IN (?))) AND ((t9.ID = t5.M_FOR_ID_LIE) AND (t10.ID = t8.M_FOR_ID)))) )
OR EXISTS (SELECT ? FROM M_VFO t11, M_FOR t13, M_FOR t12
WHERE ((((t9.ID = t12.ID) AND (t11.ID IN (?))) AND (t1.ID <> t11.ID)) AND ((t13.ID = t11.M_FOR_ID) AND (t12.ID = t13.M_FOR_ID_LIE)))) )) AND (((t3.ID = t0.AET_ID) AND (t2.ID = t3.M_FOR_ID)) AND (t1.M_FOR_ID = t2.ID)))
ORDER BY t0.CODE ASC
The JPA get's confused with the scoping of the M_FOR table. We use the same table again in different subqueries. T5 is reused in the second qubquery which is wrong (it's not in the FROM). and thus we get a ORA-0904 error.
So I was hoping that I could solve this problem by upgrading to JPA version 2.4.1 which I did using the following tutorial :
http://docs.oracle.com/cd/E23943_01/doc.1111/e25034/tlandwls.htm#BABEDCEI Section 2.3.3 Task 3: Update the Version of EclipseLink in WebLogic Server.
Basically I made a shared-library with the 2.4.1 JPA and reference it from our project.
With the 2.4.1 version I run into a org.eclipse.persistence.exceptions.JPQLException on A LOT of queries even before the queries are compiled into native sql:
I have simplified a query to make it understandable :
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT eleve FROM Eleve eleve WHERE CONCAT(eleve.nom, 'what is going on here') IN :modCodeList ].
The IN expression does not have a valid expression
I have the impression that the left side of a IN expression can't be a constant. If I put (eleve.nom IN :list) this query passes. If I put (1 in :list) the query fails for the same reason.
I have double checked the runtime version of eclipselink with:
logger.debug("ECLIPSELINK VERSION " + org.eclipse.persistence.Version.getVersionString());
So to summarize, I have native sql problems (incorrect sql) with versions 2.3.* and I have parsing exceptions with versions 2.4.0 and 2.4.1. I suppose that with versions 2.4.* I will run into the same native sql problems of versions 2.3.* once all the queries parse.
Versions 2.1.3 and 2.2.0 work.
Has anyone any idea or experience with migration problems of weblogic and/or eclipselink. Any help would be very appreciated.
EclipseLink 2.4 uses the Hermes parser by default instead of the ANTLR parser used previously, so that might explain the parsing error differences. Both issues should be filed as bugs, but it might be that once the 2.4 parse error is fixed or a workaround provided to generate the correct SQL - the code generated by the two parsers can be slightly different.
But please file both issues with as simple a test case reproduction as possible, and remember to vote for each if filed on EclipseLink instead of through Oracle support.