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
-
3
votes1
answer164
viewsManytomany mapping. Bean problem
After doing the Manytomany relationship between tables I don’t know how to save on my bean. I have a class schedule that has one or more lawyers taken care of this term. The lawyer can also be…
-
3
votes1
answer1778
viewsObject persisting problem with @Manytoone - JPA/Hibernate
I have the following problem: I can save/persist the two objects below, but JPA is not linking the ID of the DeclaracaoImportacao in the column ID class/entity . Follows code @Entity @Table (name =…
-
3
votes1
answer282
viewsBetter definition of Entitymanager
I’m studying on JPA along with the Dependency Injection and read some points on the EntityManager: If we use the following method: public EntityManager getEntityManager() { EntityManagerFactory…
-
3
votes2
answers928
viewsClose entityManager after operations? How to manage?
I have been doing some courses and all the material I have read so far exemplifies the use of JPA/Hibernate in small examples, however, when we are developing something more concrete as a project,…
-
3
votes1
answer300
viewsObject is not updated
In my flow it’s like this: I already have an object stored in the database. When loading my page, these objects are searched in the database, treated to be displayed. Objects arrive in a List…
-
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…
-
3
votes1
answer2436
viewsWhat is the (real) usefulness of the javax.persistence.Transient annotation?
The annotation @Transient serves to inform JPA that that attribute is not mapped in the table and/or should not be persisted. In addition, after the entity that has attributes annotated with…
-
3
votes2
answers616
viewsRollback() JPA + Hibernate
I have a problem with persisting several information in the same transaction, in case something goes wrong a part of the information is recorded in the bank and the rollback() is not executed.…
-
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…
-
3
votes0
answers177
viewsWhat is the best way to map entity with JPA composite key?
I have two tables to map in two entities. I need to list on the screen like this: Id | Produto | Cliente | Razão Social | País | Estado…
-
3
votes1
answer68
viewsHow to create a relationship using JPA that contains attributes?
Hello, I am working on a Java Web project with Hibernate, Postgres, Glassfish, and JPA/JSF usage. The problem is that my relationships were being generated with the following strategy:…
-
3
votes1
answer224
viewsProblem to write foreign key to table
I am developing a web java project - using Spring , Thymeleaf , Html, Mysql . In this project I have two classes that are related by foreign key. (Technical and Position). In my view…
-
3
votes1
answer63
viewsUndesirable result - Query SQL
Hello. I’m a problem and I don’t see a way to solve. My table data movement: My query: select avg(m.valor) from Movimentacao m where m.tipo='SAIDA' group by m.data; Man outworking: I cannot group…
-
3
votes3
answers800
viewsSpring Data JPA does not recognize the SQL 'Limit' command?
I am creating a REST API, using Spring Boot, which, using data from a table, displays random phrases. Giving a Google, I found that it is possible to generate random results through pure SQL: SELECT…
-
3
votes1
answer145
viewsEntities marked as FETCH LAZY are returning "null" even after a call to the GET method
Hello, good morning friends, Why my entities marked as fetch Lazy are returning "null" even when they are invoked through a get? What I learned in several courses is that when making the first call…
-
3
votes2
answers313
viewsSpring data Jpa implement generic methods
I have 3 services with these methods in common create(),deleteById(),findAll(),getById() and update(). @Service public class AutorService {create(),deleteById(),findAll(),getById(),update(), etc...}…
-
3
votes1
answer378
viewsJPA Deletes database data each time it restarts
Every time I restart the service, the data is deleted from the database. Has anyone gone through this and can you help? I am using Spring boot with JPA, Hibernate, Mysql, WEB and Rest. One of my…
-
3
votes2
answers598
viewsError in @Onetomany mapping with JPA and Hibernate
At the moment, I’m having a problem with mapping @OneToMany/@ManyToOne in my application. I would like it when I persist my entity Sale automatically save the sale items in single shot. @Entity…
-
3
votes1
answer53
viewsUse of only one attribute of an entity
I’m building a Rest API for Cities and Customers registration. My problem would be in relation to the Customer class that has as attributes personal data of the customer and a City, that would be…
-
3
votes1
answer110
viewsIs it correct to use @Mappedsuperclass instead of @Entity to not create a table in the database using JPA?
Explaining the problem, I need to consult a function in POSTGRES: SELECT * from pgr_dijkstra('SELECT gid AS id, source, target, length AS cost FROM ways', 11111, 22222); "pgr_dijkstra" is a POSTGIS…
-
2
votes1
answer708
viewsHow to store date/time of change in BD using Hibernate Envers?
I need to keep a log of all transactions of an entity with Hibernate Envers. I set persistence.xml as below: <!-- Configurações do Envers --> <property…
-
2
votes1
answer195
viewsLimit set size<> with JPA
I’m having a hard time searching Google and I can’t find a solution. I have a note in JPA with a set<> I want to limit the size of objects inside the set, that is, the code below:…
-
2
votes1
answer148
viewsSoftware to query’s JPA
Is there a client (like: pgadmin3, Oracle SQL Developer, Mysql Workbench) for JPQL queries? I have a jpa project, and I need to debug the generated jpql’s. I saw that Squirrel does it, but for HQL.…
-
2
votes1
answer8935
viewsProblem persisting: "Cannot add or update a Child Row: a Foreign key Constraint fails..."
Tables Contact CREATE TABLE IF NOT EXISTS `sgct-database1`.`contato` ( `contato_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, `telefone` CHAR(10) NOT NULL, `celular` CHAR(11) NULL, PRIMARY KEY…
-
2
votes1
answer673
viewsTrouble creating entity with Hibernate/JPA
Good afternoon guys, a little while ago I came across a problem in which I can’t find the solution. This is the following: I have 2 classes in the database created through annotations using JPA.…
-
2
votes1
answer275
viewsHibernate Boot
You can disable the check that Hibernate does every time the app starts? That is, at the time I create the table classes and I create the columns, it is normal that the first time the app runs…
-
2
votes1
answer291
viewsProblem with table extension in Postgresql, Person and Physical Person
I’m making an application that has a register of people, is a CRUD of Person that can be both physical and legal. the problem is that in my design should be created in the database a Pessoa and a…
-
2
votes2
answers1726
viewsexclusion of a database object with jpa 2 and jsf 2
Well I’m trying to do a jpa deletion using jsf but I’m not succeeding. have my table. <p:dataTable value="#{mbProduto.produtos}" var="produtos" paginator="true" rows="10"…
-
2
votes2
answers407
viewsHow to use Mysql view’s with Spring Data and eclipselink
In the development of my project I came across a select that will require a lot of application performance, as it consists of using two Join’s. Soon came to mind the creation of a view in Mysql, but…
-
2
votes1
answer365
viewsCollection Namedquery as Parameter
I am using the Namedquery of JPA, to create a DTO. And in my Query I have as condition one IN and as a parameter of IN has values with white spaces in the middle. (Ex: 9292 929). and these values…
-
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
votes1
answer402
viewsStackoverflowerror exception occurring in @Manytomany relationship with JPA
I’m having a problem in an entity relationship @Manytomany. When I try to make a simple query in the entity that contains @Manytomany a stackoverflow occurs. My rule is simple: My…
-
2
votes1
answer1330
viewsInheritance with jpa
Hello, I have a class called Usuario that is abstract and I have the class UsuarioComum and Administrador which they inherit from Usuario, I am using JPA annotations to generate the automatic…
-
2
votes1
answer441
viewsGet list of JPA/Hibernate Persisted objects
Hello, how do I get the list of persisted objects before committing it in BD. Follow the example below: Pessoa p = new Pessoa("Joao", 21); Pessoa p2 = new Pessoa("Pedro", 17); Pessoa p3 = new…
-
2
votes1
answer1678
viewsDetached Entity passed to persist
Staff I have the following problem to persist a screen where I have a relationship of many to many, in the case groupTrabalho_employee, I have a screen that registers the working group and a…
-
2
votes1
answer1372
viewsUpdate column and table settings with Hibernate
Good afternoon. I would like to know and confirm if you have any way to update table and column definitions in each schema using Hibernate. For now, what I’ve seen so far is that Hibernate only…
-
2
votes1
answer1508
viewsJpa with Hibernate implementation does not generate postgresql tables
Good evening to all I am using Jpa with the implementation Hibernate to among other features generate tables, the problem is that from one hour to another the tables stopped being generated, someone…
-
2
votes1
answer104
viewsClient side deleted object instance and sends to the server
I wonder if anyone has ever been through this problem and how did you solve it. I am using JSP and Spring Data JPA. I delete records from the middle of a form that’s a detail using Javascript,…
-
2
votes2
answers2187
viewsExtend findAll with custom filters
I am trying to extend findAll from my JPA repository to make custom filters. I did some research and found some ideas of use with Predicates and the like but did not identify something that worked…
-
2
votes1
answer2235
viewsException org.hibernate.Propertyaccessexception: could not set a field value by Reflection Setter
I’m trying to map the following model in JPA with Hibernate: Company table: CREATE TABLE empresa ( id_empresa INT(11) NOT NULL AUTO_INCREMENT , PRIMARY KEY (id_empresa) ) ENGINE = InnoDB DEFAULT…
-
2
votes2
answers711
viewsHow to persist the String of an Enumerator in the Database?
I have the following Enumerator: public enum ETipoCasa{ Propria, Alugada, Financiada, Cedida; } And I’m trying to persist in the database the string of this enumerator as an example: Casa casa = new…
-
2
votes1
answer177
viewsIdentify an Object property in Java+JPA and change it
I’m creating a class to get a database record and write to another database. I’m using JPA and bumped into a problem. I’m doing a generic insertion and I have to clean up the ID of the table to be…
-
2
votes1
answer2863
viewsJava how to do a native query and return to a DTO list
I am using Spring Hibernate and am trying to make a native query with Join back to a DTO list. I tried using @Query(value="", nativeQuery=true) with a List but it returns the serialized attributes.…
-
2
votes1
answer5896
viewsService difference, repositories and controller
What’s the difference between services, repositories and controller in JPA. I know the repositories work with data abstraction. Who takes the database data? Mapped classes (@Entity), controller and…
jpaasked 9 years, 3 months ago André Nascimento 1,258 -
2
votes1
answer877
viewsLeakage of connections with Hibernate
My system presented sporadic crashes and I ended up discovering that this happened due to processes that opened a connection but, due to some error, did not close it (Connection Leak). I solved…
-
2
votes0
answers160
viewsJPA(Hibernate) update entities automatically
I have the following question: I realized that when using JPA (Hibernate) + Spring in a JSF (Primefaces) application my entities are not updated immediately when performing a registration, for…
-
2
votes1
answer163
viewsRelationship between classes Composite key error: not Mapped to a single Property
I have a Cvariacaoto class that has a composite key (FK_T, FK_F, FK_F_VARIACAO). Two of these primary key fields (FK_F, FK_F_VARIACAO) are also foreign key to the Fvariacaoto table, in a Manytoone…
-
2
votes2
answers865
viewsI can’t save to the database in a Spring MVC project
I will explain the project because I believe that most people usually create projects using XML, and I created the Spring MVC project by dispensing the files that configure the project as XML. The…
-
2
votes1
answer189
viewsHow to generate default values with JPA Hibernate
I would like to optimize my code and my work with the following situation. I have an address entity that has a type, ie another entity called Tpendereco. Since, this table has standard values,…
-
2
votes1
answer774
viewsJPA/Hibernate problem with competition and persistence in the JRE
I am working on a project to create a simple server running over Java SE. I am using JPA + Hibernate to perform persistence, but competing routines are a problem. I am spending a lot of time trying…