Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression
EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1819241] Fri, 10 January 2020 11:50 Go to next message
Eclipse UserFriend
Hello,

I ported a webapp to EclipseLink and on init of the queries the persistence provider fails on the query:

aused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.5.v20191016-ea124dd158): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [
            SELECT NEW net.bbstats.dto.PlayerStatDto(
              gl.playerId,
              gl.seasonStartYear,
              gl.lastName,
              gl.firstName,
              gl.incognito,
              COUNT(DISTINCT gl.gameId) AS games,
              SUM(CASE WHEN gl.hasPlayed = FALSE THEN 1 ELSE 0 END) AS gamesplayed,
              SUM(CASE WHEN gl.starter = TRUE THEN 1 ELSE 0 END) AS gamesstarted,
              SUM(gl.threePointersMade),
              SUM(gl.freeThrowsMade),
              SUM(gl.freeThrowsAttempted),
              SUM(gl.personalFouls),
              SUM(CASE WHEN gl.personalFouls >= 5 THEN 1 ELSE 0 END),
              SUM(gl.points) AS points,
              MAX(gl.points),
              MIN(gl.points)
            )
            FROM GameLog gl
            WHERE gl.roundId = :roundId AND gl.groupCode = :groupCode AND gl.rosterId IN :rosterIds
            GROUP BY
              gl.playerId,
              gl.seasonStartYear,
              gl.lastName,
              gl.firstName,
              gl.incognito
            ORDER BY gamesstarted DESC, games DESC, points DESC, gl.lastName, gl.firstName
        ]. 
[140, 141] The constructor expression has two constructor items ('COUNT(DISTINCT gl.gameId)' and 'AS games') that are not separated by a comma.
[204, 205] The constructor expression has two constructor items ('SUM(CASE WHEN gl.hasPlayed = FALSE THEN 1 ELSE 0 END)' and 'AS gamesplayed') that are not separated by a comma.
[271, 272] The constructor expression has two constructor items ('SUM(CASE WHEN gl.starter = TRUE THEN 1 ELSE 0 END)' and 'AS gamesstarted') that are not separated by a comma.
[462, 463] The constructor expression has two constructor items ('SUM(gl.points)' and 'AS points') that are not separated by a comma.
[141, 149]  The expression is invalid, which means it does not follow the JPQL grammar.
[205, 219]  The expression is invalid, which means it does not follow the JPQL grammar.
[272, 287]  The expression is invalid, which means it does not follow the JPQL grammar.
[463, 472]  The expression is invalid, which means it does not follow the JPQL grammar.
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:336)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
    at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:225)
    at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:186)
    at org.eclipse.persistence.queries.DatabaseQuery.prepareInternal(DatabaseQuery.java:631)
    at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQuery(AbstractSession.java:4502)
    at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:4462)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:645)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:868)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:811)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:256)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:772)
    ... 201 more


Is this expected behavior? I think it is not very clever to disallow `AS` in constructor expressions...

I have also posted a question on SO here:

https://stackoverflow.com/questions/59677453/eclipselink-throws-jpqlexception-on-using-select-as-in-a-constructor-express

I would very much appreciate if someone could have a look at this and state his/her opinion.

Is this a missing feature? Is it just normal behavior because JPA doesn't specify it?

Thanks
Karsten

[Updated on: Fri, 10 January 2020 11:59] by Moderator

Report message to a moderator

Re: EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1819464 is a reply to message #1819241] Thu, 16 January 2020 00:18 Go to previous messageGo to next message
Eclipse UserFriend
No one?

It looks like a missing feature to me.

[Updated on: Thu, 16 January 2020 00:18] by Moderator

Report message to a moderator

Re: EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1820557 is a reply to message #1819464] Wed, 22 January 2020 18:41 Go to previous messageGo to next message
Eclipse UserFriend
I'd agree with your line of thinking that this is a missing feature. Other then the potential complexity of the parser, there is no reason I can see support for it couldn't be added, but not truly a bug as it isn't required by the spec or anywhere else for that matter.
Re: EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1820600 is a reply to message #1820557] Thu, 23 January 2020 16:56 Go to previous messageGo to next message
Eclipse UserFriend
Chris,

thanks for your reply.

I'd like to propose two features for the JPA spec then (I have got another one).

Can you tell me where/who to direct these proposals to?

Thanks
Karsten

[Updated on: Thu, 23 January 2020 17:10] by Moderator

Report message to a moderator

Re: EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1820974 is a reply to message #1820600] Mon, 03 February 2020 17:58 Go to previous messageGo to next message
Eclipse UserFriend
I've not looked recently, but all JPA specification contact information should be available on the https://www.jcp.org/en/jsr/detail?id=220 page.

Please feel free to file enhancement requests within EclipseLink - no reason they can't be implemented here if there is interest, which might add weight for their inclusion in future specifications.

Best Regards,
Chris
Re: EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression [message #1822214 is a reply to message #1820974] Sun, 01 March 2020 12:34 Go to previous message
Eclipse UserFriend
Hmm. The link you posted is really old.

Quote:

Section 1. Identification

Submitting Member: Sun Microsystems, Inc

Name of Contact Person: Linda DeMichiel

E-Mail Address: linda.demichiel@sun.com

Telephone Number: +1 408 276 7057

Fax Number: +1 408 276 7191

Specification Lead: Linda DeMichiel

E-Mail Address: linda.demichiel@sun.com

Telephone Number: +1 408 276 7057

Fax Number: +1 408 276 7191


Sun.com e-mail-addresses?

Nope.

Do you have any current contacts? I already guessed e-mail-addresses of Linda DeMichiel and Mike Keith, who I had contact with in the past, and I know the latter one had an oracle.com e-mail-address.

Previous Topic:add arbitrary JSON to a marshaled bean
Next Topic:Merge trying to delete an existing entry while trying to add a new entry
Goto Forum:
  


Current Time: Sun Feb 16 00:39:19 GMT 2025

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

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

Back to the top