I have two JPA-entities: and I tried to write a JPQL query to extract requests that: If the parameter is false then extract all requests with empty hotelBookings and all requests where every booking have parameter jointCheckIn is set to false If a parameter is true then extract all requests that have one or more bookings with jointCheckIn is set
Tag: jpql
Does the data type used in JPA entity class for defining a column impact the creation of a query in DAO?
In java entity class, I defined a named query and data types for columns. I executed the query in a DAO class but got the error: java.lang.IllegalArgumentException: Type specified for TypedQuery [TestEntity] is incompatible with query return type [class java.util.Date]. I have not used a java.util.Date class for defining the mydate column, instead I used java.sql.Timestamp, so it’s unclear why
Select the top row in JPQL without using native query option
How is it possible to select the first row at the top of the selection without using native query option in JPQL/JPA? Answer You might be able to use a max subquery here to restrict to the “first” row: This would be logically correct if orderNumber would always be guaranteed to be unique, in which case there would only be
How to return boolean result from SQL count via JPQL
I have a simple problem with sql query. I need to get true or false, I have tried multiple methods, but without good result. This query returns 0 because I have zero records in database. Perhaps the condition should be adjusted. Thanks for all ideas. Answer Solved, thank you all.
Load child collection DTOs in JPA DTO projection query
I’m using Java EE 7 with Java 8 and Hibernate (5.0.X) on Wildfly 10.1.0-Final, and I need to load a a JPQL query result into DTOs using projections, but I can’t find any documentation on how to load the child collection DTOs as well. For instance, if I have following entities for User, Role, and Privilege: And I want to
How to use part of composite key in JPA repository methods?
I have a class with embedded Id Now in my repository I want to have a method to search only by secAccount, so how should I write findBy.. I tried findByAccountLinkKeySecAccount(String secAccount) but still no success. Answer I have rewritten your class and could add repository function as well. Here’s my implementation which you might consider taking a look at.
org.hibernate.QueryException: JPA-style positional param was not an integral ordinal
I have the following JPQL request; But it prints following error: What the reason of my problem? Answer You have no whitespace between lines also check that the ?3 param is not empty list
Unexpected empty result using spring query method
I am building an application with a REST API using spring boot and JPA connected to a MySQL database. To search for names in the User class I have implemented a query method: List< User > findByFirstnameLike( String name ); This method only returns a result on an exact match, which is not what I wanted. Have I misunderstood something
Does TransactionAttributeType.NOT_SUPPORTED make sense for retrieving entities?
Does having TransactionAttributeType.NOT_SUPPORTED on every DB lookup method makes sense? I don’t see the point in having the entity attached if it’s not going to execute an update. Does it still end up in the cache? The only time it seems useful to use the REQUIRED transcation propagation is when an update is required: Other than that I don’t really
How can I avoid the Warning “firstResult/maxResults specified with collection fetch; applying in memory!” when using Hibernate?
I’m getting a warning in the Server log “firstResult/maxResults specified with collection fetch; applying in memory!”. However everything working fine. But I don’t want this warning. My code is My query is Answer Reason for this warning is that when fetch join is used, order in result sets is defined only by ID of selected entity (and not by join