Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:30:38+00:00 2026-05-28T03:30:38+00:00

I’m trying to sort a resultset using the SQL statement Order by using JPA,

  • 0

I’m trying to sort a resultset using the SQL statement Order by using JPA, on a datetime column data type with this string, on a Mysql database:

Query query = em.createQuery("SELECT e FROM Events e Order by e.EventDateTime;");

Using the createQuery method java returns the error:

SEVERE: Local Exception Stack: 
Exception [EclipseLink-8030] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): 

org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query [Events.findByGameId: SELECT e FROM Events e WHERE e.gameId = 

:gameId ORDER BY e.EventDateTime DESC], line 1, column 59: unknown state or association field [EventDateTime] of class [com.jogogestao.entity.Events].
    at org.eclipse.persistence.exceptions.JPQLException.unknownAttribute(JPQLException.java:457)
    at org.eclipse.persistence.internal.jpa.parsing.DotNode.validate(DotNode.java:88)
    at org.eclipse.persistence.internal.jpa.parsing.OrderByItemNode.validate(OrderByItemNode.java:52)
    at org.eclipse.persistence.internal.jpa.parsing.OrderByNode.validate(OrderByNode.java:61)
at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:210)

I tried sorting by the integer type primary and all runs ok…but this is not what I want of course.
Using createNativeQuery the statement runs ok…

Query query = em.createNativeQuery("SELECT * FROM Events Order by EventDateTime;");

The only problem is that the return object is not an Events type object (from the entity) and I can’t convert to this type.

Maybe the problem is that JPA does not support sorting on datetime fields?

How can I get around this?

I’m using Netbeans 7.0.1, Glassfish 3.1.1, MySql 5.5.19 Community Server (GPL) and mysql-connector-java-5.1.15-bin.jar.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:30:38+00:00Added an answer on May 28, 2026 at 3:30 am
    SELECT e FROM Event e ORDER BY e.eventDateTime
    
    • you don’t have * – you have to specify the entity you select
    • don’t put a semicolon at the end
    • use all-lower-case keywords, capital-case entity names, and lower-camel-case property names
    • name the entity in singular, not plural (Event vs Events)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.