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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:45:42+00:00 2026-05-31T12:45:42+00:00

So my entity has: @Column(name=TS, nullable=false) private java.sql.Timestamp timestamp; My generated MetaModel has: public

  • 0

So my entity has:

@Column(name="TS", nullable=false)
private java.sql.Timestamp timestamp; 

My generated MetaModel has:

public static volatile SingularAttribute<MyEntity,Timestamp> timestamp;

I want to select by the Max Timestamp value:

Root<MyEntity> root = query.from(MyEntity.class);
Expression maxExpression = cb.max(root.get(MyEntity_.timestamp));

But I am not allowed because:

max(Expression<N> x)
Create an aggregate expression applying the numerical max operation.
<N extends java.lang.Number> Expression

Of course Timestamp does not extend Number.

How can I do a MAX on a Timestamp column using the typesafe Criteria API ?

  • 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-31T12:45:43+00:00Added an answer on May 31, 2026 at 12:45 pm

    Instead of max one should use CriteriaBuilder.greatest for Timestamp (and for Date, String and other Comparables as well). And if you ever need MIN for Timestamp, then use least method instead

    Similar kind of issue can be be faced with less/greater/equal comparisons. Firs one accepts argument that extends Number, second one is for other comparables:

    • lt vs. lessThan
    • le vs. lessThanOrEqualTo
    • ge vs. greaterThanOrEqualTo
    • gt vs. greaterThan
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity which has an ID field: @Id @Column(name = `U##ID_VOIE`) @GeneratedValue(generator
The entity has the following annotations on the id column: @Id @SequenceGenerator(name = JOB_MISFIRE_ID_GENERATOR,
ENTITY CLASS : public class MyUser implements Serializable { private static final long serialVersionUID
A have a JPA entity that has timestamp field and is distinguished by a
I have the following 2 entities: @Entity(name = Employee) @Table(name = EMPLOYEE) public class
I have the following entity (getters and setters ommited)... @Entity @Table(name = TBL_PROJECT_RUN) public
i have a java class used as an entity that has 2 classes that
My entity has bean validation annotations @NotBlank and @Size on the name field. However,
I have two entities: Event and Comment. @Entity @Table(name = events) public class Event
@Entity @Table(name = J_CNTRY) public class CountryEntity { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator =

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.