Most voted "criteria" questions
A typical ORM frameworks mechanism that allows the creation of queries in the database in a dynamic and object-oriented way. When writing a query using Criteria an API is used instead of writing a query using a defined language (SQL).
Learn more…57 questions
Sort by count of
-
11
votes2
answers2459
viewsCriteria API - Hibernate vs JPA 2
I will try to phrase this question in the least opinionated way possible in the spirit of stackoverflow in English. For a new project I need to make the decision between using the JPA 2 or Hibernate…
-
5
votes1
answer588
viewsDifferences between Criteria and HQL
In the booklets I read and tutorials I accompanied the Criteria is more used, but I identified more with HQL. But I have the following doubt, all that is done with Criteria it is possible to do with…
-
4
votes1
answer110
viewsCriteria of the grails
Someone please tell me what this ${result[0][0]} means because they put two pair of brackets? def criteria = Person.createCriteria() def result = criteria.list { projections { max('age') min('age')…
-
3
votes1
answer1776
viewsUnit test/ Mock of a JPA query
Hello, how do I generate a unit/mock test of a JPA/Criteria query ? What can I guarantee by mocking my objects? Table structure? What should I mock? The consultation is very simple, only one select…
-
3
votes1
answer218
viewsHibernate Criterias - Group Dates
Currently I can group dates using Projections.sqlGroupProjection(). When my date field is in the same class as I create the Criteria, it works perfectly. The problem is when I create an alias, and…
-
3
votes1
answer92
viewsProduct displayed is the smallest within the group (Criteria)
I have a function in the system that I am developing that returns a list of lots in which the batch quantity is greater than zero, searching for the product name (foreign key). Up to this point I…
-
3
votes1
answer458
viewsorg.hibernate.Propertynotfoundexception: Could not find Setter for sum on class Class
People I’m trying to list the best selling products using Sqlquery (if anyone knows of other ways to perform as eg using Criteria, Projections also accepted) with Hibernate, but this error is…
-
3
votes1
answer509
viewsUsing Criteria for sorting
In the system I am developing I am trying to use the criteria to be able to execute a query that I am not able to make work by jpql, so I tried to execute according to the material I had getting to…
-
2
votes0
answers425
viewsCriteria: Subquery with multiple columns
I have the problem and I can’t solve it. How to turn this query into Nhibernate Criteria. SELECT ordid, prodid, qty FROM item WHERE (prodid, qty) IN (SELECT prodid, qty FROM item WHERE ordid = 365)…
-
2
votes1
answer831
viewsSubquery in the select clause with JPA Criteria
I was searching how to do a subquery in the select clause with Criteria of a select of this type: SELECT tabela1.*,tabela2.*, (SELECT MAX(tabela5.AtrDatatabela5) FROM .Tabela3 AS tabela3 INNER JOIN…
-
2
votes2
answers822
viewsMake a consultation with Ibernate criteria with Spring
Good evening, friends, I have a question. I have a Class called Proposal and another Customer Call. In the client there is the CPF field and a Proposal has a Client. I need to search for…
-
2
votes0
answers24
viewsHow to get the count and objects with jpa criteria?
need to return the grouping results and also the number of each item of a query with criteria jpa. public List<Dica> obterDicaPorUsuario(){ final CriteriaBuilder cb =…
-
2
votes1
answer746
viewsConsulting in a list (IN) - Predicate and Specification - JPA Criteriabuilder
Hello, I have to create a dynamic query based on the following scenario in a RESTFUL application using Springboot and JPA (I am using Jpaspecificationexecutor): I have two entity classes (Entity),…
-
2
votes1
answer155
viewsDTO with List using Jpacriteria
I have two entities Scheduler and Intervalodehoras. These two entities have other relationships that when I do a search with Rest, comes a lot of data unnecessary. To avoid this I created two DTO…
-
2
votes0
answers161
viewsJPA Criteria - Using between with Subquery
"The numbers at the beginning of the consultations and the "criterias" were inserted to facilitate the explanation. (1-...)(2-...)(3-...)" I need to do this on JPA criteria: SELECT DISTINCT…
-
1
votes1
answer989
viewsCount with Hibernate Criteria
I have two tables, Products and Itensvenda In the itensvenda table I have a FK of products. I want to make the following query using Hibernate criteria. select count(itensvenda.prdcodigo),…
-
1
votes0
answers63
viewsAdding up results
I’m starting to use the framework uaiCriteria and I need a result that is a sum of records in a period. Something like (simplified): select sum(valor), sum(desconto), data, idpessoa from tabela…
-
1
votes2
answers140
viewsAND operators and OR
I recently started using the Criteria API because I need to make queries that would be very complex with HQL. How I use the operators AND and OR in queries with Criteria API?…
-
1
votes1
answer97
viewsCriteria query with contains expression in the Manytoone entity field
Considering the two entities below: /** * @ORM\Table(name="cliente") * @ORM\Entity */ class Cliente { /** * @ORM\Column(name="id_cliente", type="integer") * @ORM\Id *…
-
1
votes1
answer65
viewsDoubt about Hibernate Criteria
I am trying to make a system for service order just for me to train. In the service orders I can have several categories. And my doubt is time to display, for example, a ranking of the most used…
-
1
votes0
answers154
viewsQuery using Firebird "SUBSTR" with Inline, QueryOver, Criteria
Guys, I need to create a query using the "SUBSTR" function of Firebird with Line, queryOver or Criteria. I have option to create with HQL or SQL, but these would be my last options. Anyone have an…
-
1
votes2
answers233
viewsHow to make this consultation with JPA?
I would like two solutions to this question, one using a normal typedquery and the other using the criteria due to its great versatility for code. Here is my query: TypedQuery<Pessoa> query =…
-
1
votes1
answer186
viewsSelect Hibernate criteria with mapped entity
has how I make a select, using the criteria and bring an uncharted entity, would be several joins, and sometimes bring certain fields and others not.
-
1
votes0
answers23
viewsCompare Year and Count Registered in Bank
I wanted to count registered clients in my bank, born in the year 1930 until the current year (2017). In my bank I have registered as date, date of birth ex: 2000-10-01 So I wanted to make one for…
-
1
votes1
answer99
viewsDistinc Criteria Hibernate java
I have the following context: class Entidade1 private Long id; private int commentId; private int userId; class Entidade2 private Long id; private String descricao; - I have the following criteria…
-
1
votes1
answer507
viewsCriteria to filter a string array list
I have a relationship n:n amid AgendaTriados and Indicacao thus forming the triados_indicacao. Saved in the database a array of string of the names of the indications. I want to do a survey using…
-
1
votes0
answers257
viewsHow to compare the day of a Localdate in Criteriabuilder
I have an entity that has a Localdate field. @Entity @Table(name="feriado") public class Feriado implements Serializable{ private static final long serialVersionUID = 1L; @Id…
-
1
votes0
answers260
viewsIntegration test send e-mail
Today I have a system, which sends several emails. Many settings and upload rules. I need to add about 50 new rules, new emails Time formats with attached file, images and other "cositas" more. Like…
-
1
votes0
answers37
viewsDúvida Criteria
I can do a criteria with an entity that is not mapped in another entity? Or I have to use native query to do this query? I have a user entity and another product but I have no product relationship…
-
1
votes1
answer604
viewsSearch using Criteria with WHERE, AND and OR
I’m trying to do a survey using Criteria, the research would be this: SELECT * FROM lefacil.pap_produto a WHERE (a.marca='Fabber Castell' or a.marca='Tilibra') AND (a.quantidadeCores='12 Cores' or…
-
1
votes1
answer117
viewsJPA - There is the possibility of using Matchmode.ANYWHERE with Predicate
Usually when I need to do a search picking up a result through a single word, using Criteria and Restrictions I do as follows: criteria.add(Restrictions.ilike("nome", filtro.getNome(),…
-
1
votes2
answers1009
viewsSpecification with Spring Data Jpa passing null parameter
I’m using the Specifications Spring Data JPA, but I’m having a hard time! By not passing any parameter in the two fields I want it to return all records to me. But when making the query it is…
-
1
votes1
answer346
viewsJoin fetch multiple returning duplicate values JPA Criteria API
In the method in question I want to return the consultation with the joins of employee and company. However, the Company class is related to the Query and the Employee, and is returning duplicate in…
-
1
votes1
answer387
viewsQuery with JPA filtering by Entity List
I’m performing a system in Java using Springboot and JPA, being event management and have two entities: Inscricao and HorarioAtividade. They have a relationship Many To Many, with my class Inscricao…
-
1
votes1
answer879
viewsVBA Excel - Index Match with two conditions
I have a spreadsheet with several tabs. In the first tab I have the following table: In tab 2 type the client and the type, and I wish to return the ID. For this I am using the following code in…
-
1
votes2
answers874
viewsJava: create Inner Join using criteria
I’m having a hard time finding good examples of how to create a query criteria using Inner Join. I created the query below that would be what I would like to do with the criteria. SELECT DISTINCT *…
-
1
votes0
answers25
viewsJava criteria return Function
I have a call to a function to the database using criteria, but I can’t get the result that returns in an Expression, my doubt and how to get the value returned by Expression? public…
-
1
votes0
answers20
viewsHow to use left Join fetch in Criteriabuilder by returning a dto
in the implementation below, in which return a dto built with the entity Lancamento, in which it has uni-directional relationship with category. To avoid the n+1 problem I tried using left Join…
-
0
votes1
answer50
viewsProblem with Like for Criteria
Good morning. I have a table in the following format: I need to select to return the sum of infrastructure values grouped by year. I created this query in SQL: select YEAR(dataCompraInfra),…
-
0
votes1
answer44
viewsType problem with Projectionlist in criteria
I’m having a problem in java giving the following error: in class: com.app.myApp.ReportDTO, setter method of property: indicator expected type: java.lang.Double, actual value:…
-
0
votes1
answer77
viewsHow to subselect/subquery using Criteria
Can someone help me find the problem of this consultation : CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Solicitacao> query = builder.createQuery(Solicitacao.class);…
-
0
votes1
answer232
viewsHibernate + Criteria: could not resolve Property
I’m trying to search my bank when making the User registration. Next, in my user registration have two Spinner(Company, Person) I would like to popular the person Spinner with only the people…
-
0
votes0
answers22
viewsHibernate Criteria: Sort list by highest date of a child object
How do I create a Criteria to list an object ordering by the longest date of a child object. In this scenario: Domain: class Entity { List<Children> childrens; } class Children { Date date }…
-
0
votes1
answer56
viewsCreate selects with Hibernate criteria Generico
I’m making a web software, administrative, it has several graphs and several tables, the problem with that is that several graphs and tables generate many queries to the database, and with that,…
-
0
votes1
answer390
viewsDynamic query using JPQL
I need to implement a dynamic query logic, in BD using JPQL, and I have 4 filters: 1 - PROJECT COORDINATOR 2 - SERVICE PROVIDER 3 - PROJECT START DATE 4 - FINAL DATE OF THE PROJECT Any of the fields…
-
0
votes0
answers47
viewsCriteria Hibernate - Error
I’m getting the following Exception, I analyzed my code and I am not able to find the error. The query is performed and returns the objects, but when returning, launches the Exception.…
-
0
votes0
answers39
viewsCriteria releasing Java heap space due to the size of Clause Restrictions.in()
I am trying to run a query using Criteria but it is returning a "Java heap" Exception. It’s probably because of the amount of data I’m going through in the "in" here below a code that represents my…
-
0
votes1
answer1530
viewsHow to make a Criteria Join for this query
While researching a little I realized that there are some ways to make a Join using criteria. One of them is using an alias and the other using a root. How to do the query below in Criteria using…
criteriaasked 6 years, 8 months ago Vinicius Silva 300 -
0
votes1
answer41
viewsInsert using Many to Many Annotation does not work
Hello, I have a Many to Many relationship between TEAM and NEWS. I am trying to create a method to insert a "NEWS". I am using Hibernate with Annotation to map the classes. The Insert works and…
-
0
votes1
answer166
viewsCriteriabuilder
Good evening. Please, I would like to ask you for help for the code below. It returns the total value (total values, saved in the database), but I need to return by month. I tried everything I knew,…