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

  • Home
  • SEARCH
  • 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 6749279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:40:17+00:00 2026-05-26T12:40:17+00:00

i have a strange situation: I’m using jpa/hibernate to get rows from a mySql

  • 0

i have a strange situation:

I’m using jpa/hibernate to get rows from a mySql DB table where a date column is greater or equal to a date i send in (stripped out irrelevant code):

SELECT sp.* FROM spaceproduct sp where sp.enddate is null or sp.enddate >= :endDate)

in my code i basically do:

q.setParameter("endDate", new java.util.Date());

Now, my problem is when the date in the DB is the same date. i.e. “today”, it doesn’t get picked up. I assume that it’s because it somehow also compares the time portion of the java.util.date to what’s in the database (db value is “2011-10-28′ only but the java.util Date is 2011-10-28T13:36:43.130+0200)

However, if i change the date parameter i set into a java.sql.Date(), it works!

Now, given that my mySql DB column is a Date, and not a DateTime, isnt this a bug? Even if i send in a java.util.date, shouldn’t it only compare the date part since my DB column is a date?

EDIT: i tried using a util-date and convert it into a sql-date. That actually doesn’t work either:

java.util.Date utilDate = new java.util.Date();
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
q.setParameter("endDate", sqlDate);

So from what i can see, i have to set the time part to 0 also for sql-dates, unless i use the deprecated “year-month-date” constructor…

  • 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-26T12:40:17+00:00Added an answer on May 26, 2026 at 12:40 pm

    You can use System.currentTimeMillis() rather than creating a util Date to get that long. I would expect your edited code to work however, but if it doesn’t you have no option but to discard the hours/minutes/seconds/milliseconds in some way such as doing System.currentTimeMillis() % 24 * 60 * 60 * 1000 (of course better to store that in a constant, but it gets the point across). Or you could just use Joda.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange situation using asp ajax chart controls. I have an application
I really have a strange situation. I'm making a Linux multi-threaded C application using
I guess this is strange situation. I have a results table which contain 100k
I have a strange situation on a production server. Connection for asp.net get queued
I have a strange situation with PHP working differently from HTML. I'm not a
I have just encountered a strange situation. I have some basic html: <table bgcolor=#FFFFFF
I have a strange situation. I'm using NexPlayer to render streaming video in openGL
I have a strange situation where using @parent, or even explicit id-s dont work
I have a very strange situation. I have a large set of records to
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but

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.