John Manak
John Manak

Reputation: 13558

JPQL and date comparison (constraint in the query)

My Application model object contains a date field (time stamp):

@Entity
@Table(name = "MYTABLE")
public class Application {

   private Date timeStamp;
   ...
}

I'm trying to construct a JPQL query that would select all applications that were changed today (i.e. their time stamp was changed anytime today). What is the best way to do this?

Upvotes: 2

Views: 2067

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570355

There is no perfect way with standard JPQL, JPQL doesn't provide Date arithmetic functions. But your provider might provide extensions (e.g. Hibernate and EclipseLink do). Or use a native SQL.

Upvotes: 3

Related Questions