Most voted "jpql" questions
The Java Persistence Query Language (JPQL) is an object-oriented, platform-independent query language defined as part of the Java Persistence API.
Learn more…50 questions
Sort by count of
-
5
votes1
answer201
views -
5
votes1
answer1147
viewsHow to query in Manytomany tables?
I have two tables/entities in the database with the following attributes: Car (code, plate, color) Acessorio (code, description). public Carro buscarCarroComAcessorio(Long codigo) { return (Carro)…
-
4
votes2
answers851
viewsIs it possible to limit the number of lines in a class attribute that is a list via JPQL?
I have the query below in JPQL FROM User u INNER JOIN FETCH u.enderecos e WHERE u.id =:id ORDER BY e.id DESC A user can have more than ten addresses, so we want to bring only ten addresses and if…
-
4
votes1
answer48
viewsquery executes in the database but in the project points error
I have a query native: SELECT dist.nome Distrito, enti.nome Entidade, dist.id_distrito, dist.codigo_dne, dist.id_entidade, dist.id_municipio, dist.id_uf, dist.flag_ativo, muni.nome Municipio,…
-
3
votes1
answer408
viewsSearch in associative table
How can I do an associative table search ? There are two entities, Pessoa and Time. Where I came from the Personal association_time that has id_person and id_time. My goal is to list all the id_time…
-
3
votes1
answer61
viewsHibernate Cache with select Count
Hello! I have a JPQL consultation, with count: public Long quantidadeFaturasAbertasAssinante(Integer idAssin){ return manager.createQuery("select count(f) from Fatura f where f.dataLiquidacao IS…
-
3
votes1
answer750
viewsJPA make a Join of a table that has attribute @manyToOne and @Manytomany
I have a question regarding table junctions ,I have a class sale the same has Customer,dTCompra,listProducts.I would like to make a report with the product name,customer name ,product value and…
-
2
votes1
answer2941
viewsHow to do custom query with JPA+Hibernate
Hello, I would like to know an elegant way to make a custom consultation using JPA. Basically I want to run the query and that it return me an object list, but usually it will be a query with N…
-
2
votes2
answers2446
viewsSelect JPA and Hibernate
I have five entities (Quotation, Sector, Partner, Items and Items), where the user will select a quotation and sector and the list of all items related to this sector will appear, along with the…
-
2
votes0
answers237
viewsProblem in left Join JPA - JPQL
Exception in thread "main" javax.persistence.Entitynotfoundexception: Unable to find CNPJ with id 00001388000307 Reading the documentation, I saw that this Exception is released when it tries to…
-
2
votes2
answers7879
viewsSelect Join with JPQL
Talk guys! I’m busting my chops here on my TCC and I need your help. I know the trouble I’m in must be very silly, but I don’t have much knowledge. I searched everywhere, JPQL documentation and…
-
2
votes2
answers2620
viewsHow to resolve? No converter found capable of Converting from type [java.lang.String] to type [@org.springframework.data.jpa.Repository.Query]
So Guys I’m having a problem when performing a query through a @query, well basically what I need is a list of a status column in the bd that returns only students who are with the status "Finished"…
-
1
votes1
answer523
viewsError in JPQL query
When I am starting my server the following error is happening unexpected token: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IServidorMensalRepositorio':…
-
1
votes1
answer91
viewsJPQL Query for Data Insertion
How can I enter a data with JPQL containing values: @Query("insert into user values()") User insertUser(); Dice: nomeUsuario emailUsuario…
-
1
votes0
answers225
viewsChange JPA/JPQL record
I am doing my first WEB project and I have a question about using JPA/JPQL/MERGE. The doubt is as follows: I need to change a record of a table, I created a datatable that returns to me a list of…
-
1
votes2
answers113
viewsHow to make a query per ID in HQL using the LIKE operator?
How do I make this consultation in HQL? select * from entidadeQualquer where id::text like '%12'; I tried the code below but it didn’t work: select c from entidadeQualquerc where c.id like '%12';…
-
1
votes1
answer692
viewsjpaRepository + JPQL + JOIN
I have the query below running in my code but using the real names of the table and fields, in this same structure below works, but how do I do to do the same but using the language JPQL, I am using…
jpqlasked 6 years, 7 months ago Leandro Jorge 79 -
1
votes1
answer521
viewsOnetomany mapping with HIBERNATE associative table - JPA
I need to do a hibernate mapping of a relationship 1:N in two tables, however there is an associative table that has as columns the ids of the other two tables. Example: The table Servicos may…
-
1
votes1
answer98
viewsGroup_concat in JPQL
I created the following`query: SELECT o.codigoChamado, o.codigoOrcamento, group_concat(o.conteudoOrcamento), o.observacaoOrcamento FROM Orcamentos as o group by o.codigoChamado, o.codigoOrcamento,…
-
1
votes2
answers327
viewsJPQL hibernate for multiple Ikes
I’m using Hibernate in my project and I’m having doubts about using multiple dynamic Ikes in my research. I have a simple field on the page where the client can enter a user’s name, but I need it to…
-
1
votes0
answers558
viewsHow to query involving more than one table (JPA) using JPQL
Hello, I have a query using SQL, now I am changing the project using JPA and I would like to change the queries in a coherent way with JPA. public void gerarConsulta() {…
-
1
votes0
answers1551
viewsUse SELECT NEW JPQL to popular DTO in a @Onetomany relationship
Talk to the guys! I am trying to popular my DTO object, whose main object has a Onetomany relationship. Follow the code for vcs observations: ## Mapped Object: public class Usuario implements…
-
1
votes1
answer237
viewsHow to bring a List in a JPQL query with constructor
Good afternoon, I’m doing a jpql query to bring up a VO(Value Object) with some information, one of them being a List. This list is in the object opCambio, however, is returning me this error: Log:…
-
1
votes2
answers1024
viewsHow to Sort List (Hibernate)
How can I order a List with java and Hibernate? I have an abstract class with this method public List<T> listarContas(String where) { String consulta = "FROM " + entityClass.getSimpleName()+ "…
-
1
votes1
answer151
viewsHelp with JPQL query
I am trying to return a group query together with the product entity by returning all the data from the product table and the sum of the quantity. I get a mistake which is this: Exception in thread…
-
1
votes1
answer125
viewsquery model.vo a solution with jpql and subqueryes
I have the following query in Mysql wanting to move to JPQL and I am doubtful in syntax: SELECT a2.produto , a2.descricao, a2.quantidade_recente, Soma from (SELECT p.codigoProduto,…
-
1
votes1
answer294
viewsHow to use SQL instead of JPQL?
This week I went through a problem, to be able to build a Java API using JPQL, but my Java API is not yet completed and I can already predict that in the future my project will need reporting, and…
-
1
votes1
answer167
viewsJPQL Not recognizing the parameter
I need to perform a query using JPQL or Spring-data keyword method. The problem is that the parameter inserted in the query is being ignored, I still could not identify the cause of it. Since the…
-
1
votes1
answer76
viewsReturning only the last value of a table and filling a collection via JPQL
I have the following tables in the database: CLIENT ID | NAME | CPF BUYING ID | DESCRICAO_ | DATA | ID_CLIENTE the CLIENT table with the columns id, name and Cpf the PURCHASE table with the columns…
-
1
votes1
answer71
viewsError picking value returned with query.getResultList(). get(0)
I need to get the value of a query, simply a field and I’m making the following mistake: java.math.BigDecimal cannot be cast to java.lang.String. My DAO is like this: public String…
-
0
votes1
answer254
viewsHow to do a random search using JPQL script in JPA2
The idea is basically to search for an X number of entities persisted randomly, and these entities cannot be repeated. The question is, is there any way to perform this type of search by creating…
-
0
votes1
answer133
viewsProblem with JPQL using JSF
I’m following a book Java EE 7 with JSF, Primefaces and CDI by Thiago Farias. In my persistence.xml, following the book, I have only the definition of my datasource, follows: <?xml version="1.0"…
-
0
votes1
answer290
viewsWork with Date in Mysql, JPA
I’m using JPA and creating an entity to store one date within the database. So far so good, the problem is that I need to display the database information according to the month of my date. Do you…
-
0
votes1
answer201
viewsSQL/ JPQL query
Friends, good afternoon. I have a table in the database called Question Inside the table I have two columns that are code (id) and question. I have a filter that I can not specifically bring only…
-
0
votes1
answer168
viewsJPQL - SQL query
good night. I have a bean, which has an init() method. One of the objectives of this init is to bring the cycle that was opened according to the course of that user, that is, If there is no cycle or…
-
0
votes0
answers110
viewsDependent checkbox
I have a problem and I was wondering if you could help me. I have a CRUD that registers cycles, these cycles can have many courses. What I wanted to do exactly, is validate the selectsOneRadios when…
-
0
votes1
answer76
viewsdoubt about JPQL
Hey there, guys. I’m using JPQL in my project to create some database access commands and I’m having trouble manipulating the language. I’m posting the snippet of code I’m having trouble with.…
-
0
votes1
answer153
viewshelp with nativeQuery
I tried to query uasndo Expression constructors and jpql , but jpql does not subqueryes and I am , so I try to do with nativeQuery . It is possible? I am getting error message. Would anyone know…
-
0
votes1
answer907
viewsError with Unexpected JPQL token
I made a select JPQL but I’m having this error: Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: where near line 1, column 151 [select pes, pEnd from…
-
0
votes1
answer116
viewsDoubt in JPQL/HQL query
I need to make an appointment in HQL and I have this entity Hibernate. @Entity @Table(name = "TB_TIPO_DOCT", schema = "FEP") @NamedQueries({ @NamedQuery(name =…
-
0
votes1
answer51
viewsJPQL Order by and LIMIT (JSF and JPA)
I’m having trouble solving a query with JPQL. Query I need to work: SELECT * from tab_historico WHERE idPolicial = 1 ORDER BY idhistorico DESC LIMIT 1 My DAO that is wrong, where I need to place the…
-
0
votes1
answer159
viewsJPQL JPA - Create a list grouped by date with the sum and profit of all items sold that day
The SQL query below is returning a wrong result to the fieldEntrega. SELECT DATE(p.dt_pedido) AS barChartLabels, COUNT( DISTINCT p.id) AS qtdPedido, SUM((item.quantidade * item.preco) *…
-
0
votes1
answer176
views -
0
votes1
answer266
viewsSpring Error with JPQL: Unsatisfieddependencyexception
I’m doing a REST API in Spring Boot and I’m having a hard time bringing the results of a Repository query. I have this MER, which is a small part of my bank: I built these two entities in Java,…
-
0
votes1
answer146
viewsJPQL Illegalargumentexception - Unexpected token: SUM
java.lang.Illegalargumentexception: org.hibernate.hql.internal.Ast.Querysyntaxexception: Unexpected token: SUM near line 1, column 1 [SUM(e.quantidade) FROM br.com.pmro.coad.modelo.Stock and Join…
-
0
votes1
answer38
viewsSelect 1:n and n:1 using JPQL
Good night, I am trying to select between 1:n and n:1 tables using jpql table categoira @NotNull @Column(nullable = false) @OneToMany(mappedBy = "categoria") private List<ProdutoCategoria>…
-
0
votes0
answers18
viewsMultiple query with JOIN FETCH command using JPQL
I own the following entity in my application: @Entity public class Produto implements Entidade{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String nome; private…
-
-1
votes1
answer220
viewsError in Spring JPQL call:
Initially I am trying to make a call GET of a Book passing with the parameter the title attribute of the Book, later I intend to make a query of a Book by passing as parameter the title and the…
-
-1
votes1
answer31
viewsHow to popular only a part of the object with a query in Hibernate
Related to that question I asked earlier about Hibernate I am building a Restful API, and making a Join with 2 tables. However I would like to bring only some attributes from my Join table. Today my…
-
-1
votes1
answer66
viewsHow to pass multiple lists in a query? Using JPQL
The problem is this: I have a controller that receives a list of Integers: [1245,12346 ...] In my table I need to consult using this list but the columns are separate, IE, the first digits are in…