I have an entity Event which has fields startDate and endDate. I'd like to select only those events that have at most x days left to the their endDate. I want to do this in JPQL and with only one query. How can I do this?
Taking the difference of temporal fields in JPQL
2.7k Views Asked by Oleksandr Bondarenko At
1
There are 1 best solutions below
Related Questions in JPA
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- How to create nested selects with sql?
- Play Framework Unable to build entity manager factory when Working with PostGIS
- Getting entity with a join table GAE
- Is it necessary to create an repository and a service for each entity?
- JPA, Hibernate can I do composite primary key which one element is foreign kay @OneToMany?
- Hibernate Search Faceting not working
- EntityManagerSetupException for multiple joins and a sub query for NamedQuery
- JPA and web app
- JPA findDistinctPropertyBy magic method doesn't work as expected when using spring-boot-starter-jpa
- Inject EntityManager in SwitchYard Junit implementation
- QueryDSL where relationship may be null
- JPA, how can i have two queries, one use lazy and one use eager for fetching?
- Duplicate entry '[X]' for key '[Y]' on JPA repository 'save' operation. Saved entity has its key defined already
- Hibernate's bidirectional OneToOne relationship not working within the same class
Related Questions in JPA-2.0
- JPA 2.0 CriteriaQuery with predicate on type being a class or any subclass of
- JPA Portability Between MYSQL and MongoDB
- JPA2 get column metadata (type, lenth, nullable, etc)
- Set Customized Validation Exception Message in JPA 2.0
- Unidirectional @OneToOne with reversed foreign key
- OpenJPA OneToMany and composite key in parent and child table
- JPA number generators without primary key and general use
- Container cannot inject EntityManager using @PersistentContext
- Returning result from 3 tables using JPA criteria
- JPA OneToMany with Jointable, deleting a link deletes right-side object
- Handling field of Integer with specific count of digits in entity
- JPA Criteria API .in-Clause with empty list
- Left Join in Spring Data JPA's Specification
- JPA Criteria Join OneToMany table where clause does not work
- Native query IN clause throwing sql error
Related Questions in JPQL
- JPA. JOIN nested SELECT "unexpected token ("
- Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions
- unexpected token: part near line 1, column 155 [SELECT NEW
- Top 5 records by size of collection
- List is not being initialize when using NEW in JPQL
- path expected join error! JPQL inner join query many to many example
- havaing error in jpql query
- JPQL manyToMany unidirectional query
- JPQL Query a list of Strings inside an Entity
- I need to write a JPQL query which returns the elements that contains all listed tags
- JPQL In clause error - Statement too complex
- JPQL: cast Long to String to perform LIKE search
- JPA counting its subclass for one to many relationship
- Access collection field in Spring Repository with custom Query
- Retrieve Data From Joined Table with JPQL
Related Questions in TEMPORAL
- How can I use System-Versioned Temporal Table with Entity Framework?
- Seed data with old dates in Temporal Table - SQL Server
- How can I plot subsets of temporal data?
- Remove admob ads temporaly
- Streaminsight maximum window length?
- Common Lisp: How to import symbols of other packages inside a lexical scope only?
- What is the name of concept: temporal numeric dataset with summing/aggregation operations?
- Some problems about temporal locality and spatial locality
- How to use HeidelTime temporal tagger inside a Java project?
- Merge operations on historic table
- How to carry out population-mean cosinor analysis in R using 'card' package
- Temporalis library in brightway2.5 AttributeError: 'NoneType' object has no attribute 'get'
- Temporal : Query on Promise with get() method call
- ArcGIS Pro table field calculation: SUM of field where multiple attributes have same value
- Bean cannot be found unless it is in upper package
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
JPA does not provide any standard date/time functions. You can use a native SQL query using SQL EXTRACT,
Or, if you are using EclipseLink you can use the FUNC JPQL operator to call a database specific function, or use EXTRACT if using EclipseLink 2.4,
See,
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Functions