Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4)
SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1065497] Wed, 26 June 2013 03:19 Go to next message
Eclipse UserFriend
Hello everybody,

It's my first post here. My name is Guillaume.
I'm currently using GlassFish 3.1.2.2 and EclipseLink 2.3.2 (provided by GlassFish).

My project is working fine, for example, a basic query (what is important is the alias in the SELECT clause) :
Query q = em.createQuery(
                "SELECT FUNC('MONTH', o.dateOperation) mois, FUNC('YEAR', o.dateOperation) annee, o.category.name categ, SUM(o.amount) "
                + "FROM BBankOperation o "
                + "WHERE o.account.client=:c AND o.account.type=:at AND o.dateOperation BETWEEN :d1 AND :d2 AND o.amount<:z AND o.category.offBudget=:f "
                + "GROUP BY annee, mois, categ "
                + "ORDER BY annee ASC, mois ASC, categ ASC").
                setParameter("c", client).setParameter("d1", d1).setParameter("d2", d2).setParameter("z", 0).setParameter("f", false).setParameter("at", accountType);
        List<Object[]> r = q.getResultList();


This query is working fine on GlassFish v3.
I'm currently trying to use GlassFish4, but I encounter a problem on this query (and all the query that uses an alias in the SELECT clause.

The error displayed by EclipseLink 2.5 (2.5.0.v20130507-3faac2b) (provided by GlassFish4) :
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Problem compiling [SELECT FUNC('MONTH', o.dateOperation) mois, FUNC('YEAR', o.dateOperation) annee, o.category.name categorie, SUM(o.amount) montant FROM BBankOperation o WHERE o.account.client=:c AND o.account.type=:at AND o.dateOperation BETWEEN :d1 AND :d2 AND o.amount<:z AND o.category.offBudget=:f GROUP BY annee,mois,categorie ORDER BY annee ASC, mois ASC, categorie ASC]. 
[b][color=orange][238, 243] The identification variable 'annee' is not defined in the FROM clause.
[251, 260] The identification variable 'categorie' is not defined in the FROM clause.
[270, 275] The identification variable 'annee' is not defined in the FROM clause.
[291, 300] The identification variable 'categorie' is not defined in the FROM clause.[/color]
[/b]	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:456)
	at com.clangen.boursomoney.facades.BBankOperationFacade.getExpensesPerMonthByCategoriesBetween(BBankOperationFacade.java:1133)


I really don't understand why it's not working.
I recheck it's working fine in GlassFish 3. And I tried to install EclipseLink 4.1 in GlassFish 4... but I think I can't because of the version of Java used to compile them.

Is there something to do with the new version to make the alias accepted ?

Thank you for your help.
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1066629 is a reply to message #1065497] Wed, 03 July 2013 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Seems like a bug in the new JPQL parser. Please log the bug on EclipseLink (also try the latest 2.5 release first).

As a workaround you could try "FUNC('YEAR', o.dateOperation) as annee", or just put the function in the groupby, "group by FUNC('YEAR', o.dateOperation)".

You can also revert to the old JPQL parser,

http://eclipse.org/eclipselink/documentation/2.5/jpa/extensions/p_jpql_parser.htm
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1101802 is a reply to message #1065497] Wed, 04 September 2013 20:52 Go to previous messageGo to next message
Eclipse UserFriend
Sorry for the delay, forgot to reply. The bug has been fixed and will be part of the next patch release (2.4.3 and 2.5.1). A nightly build can be picked up if required.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410808
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1101983 is a reply to message #1065497] Thu, 05 September 2013 03:25 Go to previous messageGo to next message
Eclipse UserFriend
Thank you very much.
Is there a procedure to install the new version in GlassFish 4 ?
Or how can I use a specific version in my EAR ?

Thank you Smile
Guillaume
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1104531 is a reply to message #1065497] Sun, 08 September 2013 10:36 Go to previous messageGo to next message
Eclipse UserFriend
You can upgrade your Glassfish install with a newer EclipseLink by following these steps:

1. Delete or move all jar files in modules (<glassfish_home>/glassfish/modules) folder beginning with org.eclipse.persistence (org.eclipse.persistence.*.jar)

2. Copy to folder modules all jars from the downloaded and unzipped file beginning with org.eclipse.persistence but not containing source (you probably don't need it).

3. To be safe, do the same with the javax.persistence.jar and use the one included in the EclipseLink OSGi bundle you downloaded.

4. If you have started at least once the server before you will need to delete the content of Felix cache folder inside your domain's folder. Example: <glassfish_home>/glassfish/domains/<your_domain>/osgi-cache/felix
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1104532 is a reply to message #1104531] Sun, 08 September 2013 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for your assistance !
I just tried that, and it works fine now.

Thank you very much for the explaination on how to update in GlassFish 4.

[Updated on: Thu, 12 September 2013 05:44] by Moderator

icon8.gif  Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1265647 is a reply to message #1104532] Thu, 06 March 2014 06:02 Go to previous message
Eclipse UserFriend
I met the same problem. When I download the lasted relased eclipselink 2.5.1 and move them to moudle folder, it does not work fine. Can you tell me some tips about this.

Looking forward your replayment. Thanks in advance.
Previous Topic:SIGSEGV in org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.checkCacheForObject
Next Topic:Next release?
Goto Forum:
  


Current Time: Wed Jul 23 14:04:04 EDT 2025

Powered by FUDForum. Page generated in 0.04499 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top