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
-
16
votes2
answers437
viewsWhat is the difference between using @Transient and Transient in an attribute of a JPA entity?
Studying some third-party codes, I came across different ways to define that a particular attribute of an Entity will not be related to a column in the database. Among the shapes I found, the first…
-
15
votes1
answer27253
viewsDifferences @Onetomany, @Manytomany, @Manytoone, @Onetoone
I wanted to build a database with Java Hibernate as below: Doubts: What’s the difference between @OneToMany, @ManyToMany, @ManyToOne, @OneToOne? And what would your statement look like in Java?…
-
13
votes2
answers13163
viewsHow to make the Genericdao class using Hibernate?
I wanted to know how to make a generic Dao of a project, using Hibernate and JPA in java. All this to not be mounting a DAO as follows for each object that will persist in the bank: public class…
-
11
votes4
answers634
viewsJPA List<Map mapping.. >
I have the following problem and I would like some advice on the best approach: Let’s assume you have a system that manages a school and would like to have the option for the system administrator in…
-
11
votes1
answer18212
viewsWhat are the types of Scade in JPA?
I’m looking for information on the types of Scade that exist and how they work in JPA relational modeling. The guys I found explanations for were: NONE = Does nothing with the object (default) MERGE…
-
9
votes1
answer1020
viewsThe name of the dt_ultimo_access column was not found in this Resultset
I’m deploying a method passing an id parameter: @RequestMapping(method = RequestMethod.GET, value = "/entidadesUsuario/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public…
-
9
votes4
answers11232
viewsJPA Object References an Unsaved Transient instance - save the Transient instance before Flushing :
When trying to save the "Addresses" of "Client" JPA/Spring returns me the following error in "main" Caused by: org.hibernate.Transientpropertyvalueexception: Object References an Unsaved Transient…
-
8
votes2
answers2937
viewsBest Way to Use and Instantiate Entitymanagerfactory
My project has the following structure: Within the package br.mandacaru.DAO are the controllers. To instantiate an object JPAController I need an object EntityManagerFactory and for that reason I…
-
8
votes3
answers1408
viewsWorking with JPA+Hibernate cache
I doubt how I should work with the objects EntityManagerFactory and EntityManager. Currently I urge a EntityManagerFactory for the whole system, since I have only one bank, I create only one and use…
-
7
votes1
answer915
viewsValidation of business object avoiding/reducing use of if’s and Else’s
I have a problem where I have three types of employee (Funcioa, Funcionariob, Funcionarioc), all will be recorded in a table called Funcio and their respective relationships, however, these types…
-
7
votes1
answer5553
viewsjava.lang.Illegalargumentexception error in Hibernate when working with Enum
Take a look at the error message: jun 02, 2015 5:23:57 PM com.sun.faces.lifecycle.ApplyRequestValuesPhase execute ADVERTÊNCIA: /WEB-INF/template/pedidos/CapaPedido.xhtml @29,99…
-
7
votes2
answers1363
viewsWhat is the relationship between JPA and ORM?
I wanted to know the relationship between JPA and ORM because I was in doubt, if both ,.
-
7
votes2
answers739
viewsProblems with Hibernate Lazy
Friends, all good? I have a problem that is the famous: org.hibernate.Lazyinitializationexception:. I know this is because the session has been closed and Hibernate can’t connect to make the selects…
-
7
votes1
answer2978
viewsPagination with large amount of data
Thinking about performance, what is the best way to paginate a large amount of data? I’m currently wearing a List<Produtos>, keeping around 500 products in it, and using subList(min,max),…
-
7
votes1
answer297
viewsMulti Tenancy with Hibernate update schema
Hello I am with an application that uses multiple databases (multi-tenancy) using Hibernate. I wonder if anyone knows any way Hibernate can update the bank schema. I’ve already set the property…
-
7
votes2
answers1171
viewsEntitymanager or Session? What to use?
I have worked with projects that used both Session and Entitymanager but it was never clear which one to choose. On what basis they differ in terms of performance and compatibility. Someone can give…
-
7
votes1
answer2011
viewsCascadetype.ALL doesn’t work. Am I using it wrong?
In my code, I have the classes Author and Book, with the relationship Many To One, as below: Java author. import javax.persistence.CascadeType; import javax.persistence.Column; import…
-
6
votes1
answer895
viewsDuplicate records with Onetomany relationship
I have a map as follows: public class ClasseA { public ClasseA(){ listaClasseB = new ArrayList<ClasseB>; } @OneToMany(mappedBy = "xxxx", fetch = FetchType.LAZY, cascade = CascadeType.ALL,…
-
6
votes1
answer323
viewsJPA, Hibernate, Spring MVC, Maven - Definition
I’m having a lot of questions about definitions! My goal is to build a system architecture, but the definitions of JPA, HIBERNATE, SPRING MVC, MAVEN, are obscure. JPA: It is nothing more than a…
-
6
votes2
answers230
viewsInvalid Property 'category.subcategory' of bean class. Error saving user to database
I am developing a web application that has the following mapping: A user has a category; A category has several subcategories; a subcategory has several products. As shown below: What I am trying to…
-
6
votes3
answers720
viewsNullpointerexception Java JPA CDI Tomcat
Good afternoon guys. I am developing a Java test application with JPA, CDI and Tomcat. I created a basic test class and am getting the following error. Erro: Exception in thread "main"…
-
5
votes1
answer812
viewsLoad objects related to @Onetoone
concerning the doubt that I have is basic, but it is taking my sleep. I have an entity in which I call Destination. In the Destination entity I have several relationships of the type @OneToOne with…
-
5
votes1
answer2052
viewsUsing Hibernate to generate tables with H2
I’m developing an application in which I decided to use H2 as an embedded database. It is the first time that I am using this type of database and I am having problems to generate the tables by…
-
5
votes1
answer961
viewsCustom auto increment
I have to generate an auto increment of the type "000"+id, but I can not get to something concrete, my base is this below, I wanted only a light even of how to do, I do not need the answer itself.…
-
5
votes2
answers1286
viewsMultiple Persistence Units with Spring Data
You can create multiple Units persistences by connecting to separate databases in the same JPA application using Spring Data? For example. I have an application that will run in Mysql normally.…
-
5
votes2
answers18970
viewsHow does Hibernate.hbm2ddl.auto work?
What values can I use on this property? ex: Update <prop key="hibernate.hbm2ddl.auto">update</prop> How does it work? When should I use? is good practice?…
-
5
votes1
answer393
viewsJPA - Registry error not found right after insertion
A question about JPA procedures, because of a mistake that happened and I’m not getting it. I’m taking care of a part of the system that feeds a card order table. It searches if the user that the…
-
5
votes1
answer372
viewsData modeling via JPA and Hibernate
I’m doing a project with JPA regarding a quotation system and I’m having doubts on how to build the relationship between classes, and would like (if possible) some opinions. My project is a quote…
-
5
votes1
answer201
views -
5
votes3
answers1598
viewsHibernate vs Eclipselink
Both persistence frameworks implement JPA. 1 - There is a difference between the two? 2 - Which is the best in performance? 3 - As the two implement the same specification, after developing a…
-
5
votes1
answer486
viewsjavax.persistence.Persistenceexception (no security manager: RMI class Loader disabled)
I created a policy file that gives permission for my machine to run both the client and the server, I also passed the ports to them. Inside the server I prompt RMI Security (since if I remove it the…
-
5
votes2
answers6061
viewsQuery specified Join fetching, but the Owner of the fetched Association was not present in the select list
I have a scenario with the following entities:Treinamento, Curso and Aulas. A Treinamento has a relationship ManyToOne for Curso. And Aula has a relationship ManyToOne for a Curso. I want to perform…
-
5
votes1
answer705
views"No Persistence Provider for Entitymanager" for Hibernate 5.x
Well, you have to update the version of hibernate that was already I want to implement in my project to avoid bugs of the past version, but I’m having difficulty making the persistence in the new…
-
5
votes2
answers1584
viewsHow to avoid infinite recursion without using the Jsonignore annotation in Springboot
I have a relationship @OneToMany amid Produto and TipoProduto where a TipoProduto may have several Produtos and a Produto may have only one TipoProduto. I’d like to list all the Produtos of a…
-
5
votes1
answer2036
views@Enumerated(Enumtype.STRING) Hibernate JPA
I have the following field classificacao in a table. This field is filled in elsewhere and is filled with, only, 'P' or 'N', acronyms for Positive and Negative. I then created the enum Java.…
-
4
votes1
answer242
viewsAttempt to update registration ID not allowed with JPA and Eclipselink
How do I allow updating the ID of a record with JPA and Eclipselink? The following exception is thrown when I try to update the ID: Caused by: Exception [Eclipselink-7251] (Eclipse Persistence…
-
4
votes1
answer2476
viewsWhy is Pattern Open Session In View considered an anti-pattern?
I wonder why many developers and architects consider the standard Open Session In View one anti-pattern?
-
4
votes3
answers474
viewsMap java.time properties with Hibernate and/or JPA
Is there any way to map properties like java.time.LocalDate and/or java.time.Instant through JPA and/or Hibernate?
-
4
votes1
answer263
viewsIntegration between Spring and JPA
I recently started studying one of the most amazing frameworks I’ve ever known, Spring. I always make good progress in my studies, I’m already studying the integration of Spring with data access…
-
4
votes2
answers4196
viewsGet list of objects with JPA and Hibernate
I’d like some help. In my code the method of entering the object in the database is working, however when trying to get a list of objects stored in the database, I get the error that my table is not…
-
4
votes1
answer306
viewsObject-relational mapping (JPA + Hibernate) using XML
For a specific reason, I need to do object-relational mapping (JPA) of my entities with XML. [Unfortunately,] I cannot use annotations to do this. It turns out that in certain properties, I need to…
-
4
votes1
answer423
viewsTry/catch does not "catch" to Exception
I’m using JPA and was trying to create an Entitymanager, and was testing some expcetions treatments in a class of mine. However, I have a problem, that Exception is not being "caught" by catch.…
-
4
votes2
answers1101
viewsRemove association in relation to Many to Many
I have a relationship @manytomany unidirectional and need to remove this association according to some criteria but did not want to have to browse through all objects in the collection to remove…
-
4
votes2
answers949
viewsProblems with JPA - Hibernate does not persist WHOLE object
Good morning guys! I have the following entities: package br.com.sistema.entidade; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import…
-
4
votes2
answers538
viewsMaven project with Hibernate and Glassfish does not generate database
I have a Maven project and I’m having problems generating the database, I’m using Hibernate and Glassfish 4. No error is generated, just no data is generated, I’m new with Maven maybe I’m forgetting…
-
4
votes2
answers412
viewsProblem when changing the type of a column in the model using JPA annotation
I have a column in the database that is limited to receiving a varchar(255), but I need to change this to a bigger size. For that I added these annotations in the field: @Column(nullable = true,…
-
4
votes1
answer1560
viewsFetch of children with JPA+Hibernate not working
I have two classes, Terminal (who is the father) and Portaria (son). I’m using JPA and it’s working, but there’s a bug I can’t fix. I upload a list of Terminal and when testing the t.getPortarias()…
-
4
votes1
answer785
viewsN-N relationship with additional fields (problems to persist data)
I have an N-N relationship that works as follows: Destination.java (N)-(N) Customerservice.java Within this relationship there is an entity that keeps the relationship Ids, which has some more…
-
4
votes1
answer1304
viewsHow to persist abstract class with JPA
I know JPA and I have other tables already implemented and working. I would like to know how to persist the classes below, since one is an abstract class and the other is "extending" it. I should…
-
4
votes1
answer580
viewsHigh memory consumption Java Swing application
I am developing a Java application but when performing some tests and noticed that when running the application, my memory consumption increases. And as the use, it always allocates more and more…