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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:10:25+00:00 2026-06-12T13:10:25+00:00

Is there a way to represent the maximum (and minimum) possible date in JPA

  • 0

Is there a way to represent the maximum (and minimum) possible date in JPA without being database specific? The JPA implementation should be then be able to translate it to the correct value according to the used dialect.

If not JPA an Hibernate specific solution would also be OK.

Edit

In an application we are using there are several named queries which test if a date is in a given range

SELECT ... FROM ... WHERE somedate BETWEEN startdate AND end date

If the range is open (only startdate, or only enddate) it would be easier to use the maximum and minimum date that to have different queries with just a single comparison (this would require several changes in the existing application that I would like to avoid).

Edit 2

For the not a real question voters: the question is:

It is possible to query for the maximum possible date in a database agnostic way?

Edit 3

The application is storing dates as java.util.Date as follows

@Temporal( TemporalType.TIMESTAMP )
private java.util.Date someDate;
  • 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-12T13:10:26+00:00Added an answer on June 12, 2026 at 1:10 pm

    I believe there is no such feature (yet) to get the max/min date in DB neutral manner.

    I’d suggest you to, base on the DBMS you are going to use, define corresponding constants in both Java and DB stored functions.

    Therefore you can do something like:

    Query query = session.createQuery("from Foo where date between :fromDate and :toDate");
    query.setParameter("fromDate", DateConstants.MIN_DATE);
    query.setParameter("toDate", DateConstants.MAX_DATE);
    

    (I used to call that FOREVER and EPOCH 😛 )

    or even have HQL like this (if you have create stored function in DB)

    from Foo where date between MaxDate() and MinDate()

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

Sidebar

Related Questions

Is there some way to represent this kind of SQL with JPA or Hibernate
Is there way to automatically maximize the output window on hitting build and then
Is there a better way to represent a fix amount of repeats in a
Is there a way to represent special HTML characters in a EditText in Android?
I wondering is there a way to represent model differently (or probably control access
I know I can use number_format, but is there a way to represent base32
Is there any way to represent class's source code as objects? I'd like to
Is there a way to represent a time value in Excel where hours can
Is there any way to represent any number as sum of 4 squares. For
Is there a way to represent an object array in JSON? e.g. Supposing I

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.