Most voted "jpa" questions
The Java Persistence API (JPA) defines a path to map Plain Old Java Objects (Pojos) to a database, these Pojos are called entity Beans.
Learn more…652 questions
Sort by count of
-
2
votes2
answers116
viewsAPI method searches for information but does not appear in front-end
I have a method of my API that does a database search @RequestMapping(method = RequestMethod.GET, value = "/entidadesUsuarioPermissao/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public…
-
2
votes1
answer111
views@Preupdate com @Transient - Eclipselink
I need a @Preupdate method to be called when a @Transient attribute is modified. This @Transient will always be modified, so yes, @Preupdate would have to be called every time. Since it will always…
-
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
answers1186
viewsExtract JDBC Connection from Entitymanager using JTA
In an environment Javaee, there is the possibility to extract the JDBC connection(java.sql.Connection) using JTA? I have a datasource in Wildfly, where I inject in the following way:…
-
2
votes0
answers280
viewsManytomany Hibernate error
Hello, I have a relationship @ManyToMany bidirectional between the class Pessoa and Endereço, where for these, I have the tables in the bank for person, address and the table for the relationship…
-
2
votes2
answers198
viewsHow do select in specific columns and continue to receive an entity list and not an Object array?
Having the second class: public class Usuario { private Integer id; private Email email; private String nome; private String sobrenome; private String senha; private String usuario; private…
-
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
votes0
answers1149
viewsCould not read Entity state from Resultset Entitykey Onetomany composite keys
I’m having trouble in oneToMany relationship of two entities using Jpa Hibernate. I have two tables, one for cancellation and another that has the orders that are part of the cancellation. The…
-
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
votes0
answers70
viewsHow to change the @Generatedvalue used by Spring through Spring’s Abstractpersistable class?
I’d like to use the @GeneratedValue(strategy = GenerationType.SEQUENCE, ... ... when extending the class AbstractPersistable, but I don’t know if that’s possible. From what I saw in the…
-
2
votes1
answer242
viewsObject Serialization Error with Spring Data and Spring Web
I was creating a simple endpoint of an entity and ended up getting the following exception: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class…
-
2
votes1
answer159
viewsJava Spring - Null returns repository
This is my Apikey class: @Entity @Table(name="API_KEYS", schema="DEMO_PIMS") @JsonIgnoreProperties(allowGetters=true) public class ApiKey implements Serializable{ private static final long…
-
2
votes0
answers37
viewsDynamically connect to an Oracle database with each JAX-RS request
I’m developing a project on Jboss Seam to provide some services via JAX-RS on Wildfly 9. The DBMS used is Oracle 10g, and the services that will be made available are form features that the company…
-
2
votes0
answers88
viewsJPA - Cascadetype.REMOVE after entity is deleted by orphanRemoval=true
public class PrimeiroNivel { @OneToMany(mappedBy="primeiroNivel", orphanRemoval=true) private List<SegundoNivel> niveisSecundarios; } public class SegundoNivel {…
-
2
votes1
answer135
viewsNative query count does not return the same type in SQL Server and H2
Hello, I have a native consultation that makes a simple count of records from a table: public Long contar() { String sql "SELECT count(*) FROM Order"; Query query = query.createNativeQuery(sql); //…
-
2
votes1
answer126
viewsJPA returning Object different from class object type
The following query returns java.lang.Classcastexception: [Ljava.lang.Object; cannot be cast to br.com.satisfacer.model.Client public List<Cliente> teste(Cliente cliente) { return…
-
2
votes0
answers42
viewsDifficulty with JPA annotations for entity relationships
I have the following relationships: Categoriapeca, Subcategoriapeca and Peca. One Categoriapeca may have several Subcategoriapeca, and a Subcategoriapeca may have several Categoriapeca, a piece can…
-
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
answers110
viewsHibernate does not consider field for Insert
I have a class Cliente which has composite key: @Entity @Table(name = "Clientes") @IdClass(ClientePK.class) public class Cliente implements Serializable { //@EmbeddedId //private ClientePK…
-
2
votes0
answers256
viewslocalhost redirected it too often
Good afternoon, I am trying to direct a system user to an error page in case something goes wrong with the session or if the user is denied access to a particular page etc... I’m using Spring…
-
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…
-
2
votes1
answer63
viewsHow to make a JPA query with mappings @Manytomany
Good morning. I’m having trouble performing a query in the database where my Employee entity has 2 mappings @Manytomany and 1 mappings @Manytoone. When performing a query the Employee and Projects…
-
2
votes2
answers66
views -
2
votes1
answer219
viewsHow to reference more than one ID attribute using the jpa API?
My question is whether I can use the annotation @ID several times in a row, if this is possible or if there is another way to reference attributes of the type ID after the first. import…
-
2
votes1
answer325
viewsEnum error with JPA + Hibernate
When performing a query in the database with JPA + HIBERNATE the following exception shall be made: java.lang.IllegalArgumentException: Unknown name value [Respondido] for enum class…
-
2
votes0
answers47
viewsDesign using SPRING MVC does not perform CRUD on the bank correctly
I have a Controller with some implemented methods that save, update and remove my object pr of the kind professorRepository on the bench. I am using the Spring boot for this project, then the CRUD…
-
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"…
-
2
votes1
answer1387
viewsSpring Boot, ultilizar outro campo de busca além do @id
I am making an API with Java with Spring boot and I would like it to search for CPF and not ID; http://localhost:8080/pacientes/ID http://localhost:8080/pacientes/Cpf (sera informado pelo usuario)…
-
2
votes2
answers136
viewsSPRING - Count the number of queries made in a request
I have a simple requisition GET for example, to search a product for your ID: @Autowired private ProdutoRepository produtos; @GetMapping public Optional<Produto> listarProduto(){ return…
-
2
votes1
answer1199
viewsHow to Map One to Many Correctly in Hibernate
Good afternoon, I am creating a very simple Restful API that implements an online course system, where I have only 2 tables "Courses" and "Teachers" (And I am trying to learn Latin in the process):…
-
2
votes1
answer75
viewsWho implements the Spring Repository interfaces?
We have the interface JpaRepository which we can use from your import with: import org.springframework.data.jpa.repository.JpaRepository; From it we have the standard methods to use, such as the…
-
1
votes1
answer142
viewsProblem with JPA
Classes and persistence.xml below. The problem is: entityManager is Coming NULL. @ManagedBean(name="pessoaController") @SessionScoped public class PessoaController{ private List<Pessoa>…
-
1
votes1
answer979
viewsJPQL to view bank date/time with Hibernate without query
There is a way to query the database date/time without using activate query? On the Oracle I do this: SQLQuery qry = session.createSQLQuery("SELECT SYSDATE FROM dual"); But I would like a general…
-
1
votes1
answer1873
viewsProblem when inserting data into postgresql with jpa implemented by Hibernate
Good afternoon I would like to know why this error is happening, the project is with all the jars in the lib and in the path but when I will insert is returning me an error. Apr 19, 2014 4:49:27 PM…
-
1
votes1
answer1051
viewsProcessing of database exceptions
How to handle database exceptions with JPA? And, how to use annotations instead of the Imessage interface, as below? Example: My database returns error: "Violation Constraint uk_email"; Pick up the…
-
1
votes1
answer138
views -
1
votes1
answer259
viewsRendered of the first faces giving error while recovering entity Boolean
Can anyone tell why the rendered Graphic image is giving error??? <p:dataGrid columns="3" value="#{projetistaBean.listaDeProjetistas}" var="projetista" styleClass="ui-datagrid" >…
-
1
votes1
answer840
viewsErro em relacionamento Manytomany no Hibernate
I have a problem with @manyToMany. You’re making the mistake: org.hibernate.Multiplebagfetchexception: cannot simultaneously fetch Multiple bags Follows my model: @Entity @Table(name = "sar_evento",…
-
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
votes0
answers159
viewsInstability recovering updated objects list
I am facing problems with Hibernate that seems to be related to the cache object. I have an entity, let’s call it A, with an attribute mapped list with @OneToMany (cascade = CascadeType.ALL,…
-
1
votes0
answers118
viewsHibernate + Maven + Glassfish
I have a Maven Project, which uses Hibernate, and has all the dependencies ok. I’ve already created the connection pool in glassfish. The problem is that even the class mapped with the annotations…
-
1
votes1
answer2319
viewsCheck if the user informed data already exist in the database before entering
I need to check in the database if the information that the user is trying to enter already exists, for example: In the registration of a company, I cannot allow the same CNPJ for others. I am doing…
-
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
answer66
viewsError in Namedquery
Good evening guys, I’m looking to create a namedquery with a bank appointment. Follows: @NamedQuery(name="ListagemProdutosMesa",query="select Produto p FROM Produto p, Pedido pe, Conta c,…
-
1
votes1
answer390
viewsError switching H2 application to Postgresql
I was developing a bank application H2 just for testing and everything was working. At the end of the implementation I changed the connection to JPA to the PostgreSQL, only when I did this the…
-
1
votes2
answers1483
viewspersistence.xml for development and other for production?
I have my persistence.xml configured for a local database. <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/meubanco"/> <property…
-
1
votes1
answer181
viewsHow do I popular an arraylist<Type> with a result brought from the mysql database, using Hibernate?
On many topics I see an excerpt of code that I can’t reproduce: Query query = session.createQuery() I cannot create this Session object using the createQuery() method. Can someone show me an example…
-
1
votes2
answers339
viewsIncomplete entity class problem - JPA
Personal I am trying to make the relationship between two class (Cotdetatlhe and Cotdetforn), but I am facing the following problem: The @Joincolumns on the annotated element [field cotDetatlhe]…
-
1
votes0
answers69
viewsUnexpected behavior in generation @Onetomany unidirectional (additional FK columns being created)
Below follows the two entities with unidirectional relationships: Customerservice.java @Entity @Table(name = "customer_service") @Multitenant @TenantDiscriminatorColumn(name = "tenant_id",…
-
1
votes0
answers57
viewsBean class not found - Javaweb
Good evening, I am doing my tcc in Java Web and making data persistence with JPA and Hibernete. I did the CRUD apparently right, but when I click the sign up button it gives this error.…