Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 07:19 Go to next message
Guillaume Lepinay is currently offline Guillaume LepinayFriend
Messages: 3
Registered: June 2013
Junior Member
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 14:00 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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


James : Wiki : Book : Blog : Twitter
Re: SELECT blabla AS x... => AS (alias) not working in EclipseLink 2.5 (glassfish4) [message #1101802 is a reply to message #1065497] Thu, 05 September 2013 00:52 Go to previous messageGo to next message
Pascal Filion is currently offline Pascal FilionFriend
Messages: 5
Registered: July 2009
Location: Raleigh, NC
Junior Member
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 07:25 Go to previous messageGo to next message
Guillaume Lepinay is currently offline Guillaume LepinayFriend
Messages: 3
Registered: June 2013
Junior Member
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 14:36 Go to previous messageGo to next message
Pascal Filion is currently offline Pascal FilionFriend
Messages: 5
Registered: July 2009
Location: Raleigh, NC
Junior Member
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 14:40 Go to previous messageGo to next message
Guillaume Lepinay is currently offline Guillaume LepinayFriend
Messages: 3
Registered: June 2013
Junior Member
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 09:44]

Report message to a 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 11:02 Go to previous message
Jacky Cai is currently offline Jacky CaiFriend
Messages: 1
Registered: March 2014
Junior Member
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: Tue Mar 19 03:21:20 GMT 2024

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

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

Back to the top