This code has not compile error but at run time gets this error: Cannot cast from Expression to int I tried using String: This also gets error: ERROR: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d”; nested exception is java.lang.NumberFormatException:…
Tag: criteria
Criteria API how to write = ANY(?1) expression?
I have a query that I want to translate to Criteria API. A query After java processes it (native sql query) the final query looks like this My Question is how to translate = ANY(?1) part to Criteria API? I see that any() definition is How to put array of values to it? I’m using PostgreSQL Answer You wil…
How can I build a predicate filtering to where ALL tags in an array exist, joined to a record, using criteriaBuilder?
Here’s an example of the syntax I’m using for another condition (where ANY of the tags appear on the document via a FK). predicates.add(root.join(Document_.tags).in({ pseudocode array of tags })); I’m trying to come up with a similar predicate, but where the Document entity has ALL of the ta…
Corda: How to use the AndComposition with a VaultCustomQueryCriteria
I use a RPC client (Java Spring Boot application) to connect to a Corda 4.6 node. I want to run a custom vault query with the following query criteria: This is very similar to the example from the Corda documentation. However, I just retrieve UNCONSUMED states. What could go wrong here? The following snippet …
Spring Data Mongodb Query by embedded document id
i am trying to query a model that contains a @Reference as attribute like: and so on, then i have a query with more logic and code but in resume i have to filter by the field _id from Branch object, its just id on the object but on database its _id, ok no problem its normal behavior for the
Java – JPA-Specification: how to create criteria/specification on a field that belongs to a nested object?
I am using jdk 1.8 , hibernate and jpa in my project. And using specification/criteria to build my search query. I have a class A ( an hibernate entity) which has class B as an attribute. So, roughly, it looks like : and… My repository class looks like (roughly): } Most of the simple JPA queries are wor…
How to query MongoDB with 2 conditions that has and relation
In my spring boot project, I am using MongoTemplate. My mongo document is Hotel looks this:- In my service class, I am trying to find as follows. My target is to find a hotel where the city name is an exact match and within a max price range. Following query don’t find anything. What is wrong? Answer ci…
Spring Boot Jpa specification Set Enums IN Set Enums
Hi I want filter restaurant by type using Specification, but I get error: Parameter value [SUSHI] did not match expected type [java.util.Set (n/a)] How Can I comare List enums to list enums ? :/ My specification file: Restaurant model: Restaurant category: Answer Had the same problem and this question helped …
How to paginate a JPA Query
I have a submission table with columns like ID, Name, Code among other properties. My requirement is to search for records based on the mentioned properties and return a paginated set. This is the pseudocode for what I am looking for: There seem to be many options like CriteriaBuilder, NamedQuery, etc. Which …