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 7758185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:17:34+00:00 2026-06-01T13:17:34+00:00

my problem is a bit similar to this : I want to retrieve rows

  • 0

my problem is a bit similar to this:
I want to retrieve rows whose date doesn’t has more than 20 minutes compared with the current date time, my source code:

   EntityManagerFactory emf=Persistence.createEntityManagerFactory("JavaApplication21PU");
   CoordonneesJpaController cjc=new CoordonneesJpaController(emf);
   Timestamp nd=new Timestamp(System.currentTimeMillis());//now
   nd.setMinutes(nd.getMinutes()-20);

   EntityManager em = getEntityManager();
   Query qr= em.createQuery("SELECT c FROM Coordonnees c WHERE c.date > '"+nd+"'");
    java.util.List<Coordonnees> lC=qr.getResultList();  

My entity:

    public class Coordonnees implements Serializable {
    //some code...
    @Basic(optional = false)
    @Column(name = "DATE", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;

when I run this code:

Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [%2012-04-06 16:19:49.179%], of class [class java.lang.String], from mapping [org.eclipse.persistence.mappings.DirectToFieldMapping[date-->APIGPS.PUBLIC.COORDONNEES.DATE]] with descriptor [RelationalDescriptor(javaapplication21.Coordonnees --> [DatabaseTable(APIGPS.PUBLIC.COORDONNEES)])], could not be converted to [class java.sql.Timestamp].
    at org.eclipse.persistence.exceptions.ConversionException.incorrectTimestampFormat(ConversionException.java:119)
    at org.eclipse.persistence.internal.helper.Helper.timestampFromString(Helper.java:1888)
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToTimestamp(ConversionManager.java:726)
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:107)

the error is from this line:

   Query qr= em.createQuery("SELECT c FROM Coordonnees c WHERE c.date > '"+nd+"'")

Any helps ?

  • 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-06-01T13:17:35+00:00Added an answer on June 1, 2026 at 1:17 pm

    It looks like you are comparing c.date which is a Date (Timestamp) with a String, as you are setting the nd in the string query, and surrounded by single quotes. You should use a named parameter, and set the nd variable into that parameter.

    Query qr= em.createQuery("SELECT c FROM Coordonnees c WHERE c.date > :nd");
    qr.setParameter("nd", nd);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is a bit more complex than using the following simple JavaScript code:
This problem is a bit strange. Why is showed Is not null, if the
I noticed people wrote about this circular reference problem quite a bit before but
I am working to solve a problem that is a bit similar to Euler
I've done a bit of googling round but this particular problem is a little
I want to make a similar application to Skype, and the main problem is
I have made a question which is a bit similar to this, though the
My problem is similar to this one, How to update a widget every minute
I'm failing a bit to get this working. I read out a date from
My question is a little bit similar to this but it is about TCL

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.