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
votes1
answer1339
viewsDifference between Merge() and getInstace() in JPA/Hibernate
I wonder when I should use merge() to update the object instead of changing it through its reference. Example: Produto p = new Produto(); p.setNome("Bola"); p.setvalor("32); manager.persist(p);…
-
2
votes2
answers784
viewsConfigure IP for server access using Hibernate
I have a Java application that uses Hibernate, for development I made the database configuration using localhost but for use on other computers I will need to define the IP that will have the…
-
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
answers303
viewsCache Problem - Writing database data to Java system
I have a system developed in Java using JPA, Hibernate, Primefaces. When I write system registration reflects in the Mysql database normally, until here OK, but when I do unlike the database…
-
2
votes0
answers192
viewsHow to treat exceptions with JTA?
I have a project where I am using JPA with JTA. In the method gravar, I put the note @Transactional(Transactional.TxType.REQUIRED) and in it there is a call to a validation method that can cast an…
-
2
votes2
answers1125
viewsTables are not automatically created by Hibernate in Mysql
Hibernate cannot create the table in the database already created (drogaria_teste). Below is code. Hibernate.cfg.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE…
-
2
votes1
answer785
viewsComposite key problems in JPA
Hi, I’m a little young with JPA and I’m having problems with a composite PK. Follows the class Aluno: @Entity @Table(name = "Aluno") public class Aluno { @Id private String ra; @Column(length = 50,…
-
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
votes1
answer226
viewsJPA+Hibernate releasing update alone
Hello, I have an object that is managed by Hibernate. On screen, an attribute of this object is updated the value and Hibernate immediately triggers an update in the database, without even going…
-
2
votes1
answer288
viewsHow to limit a relationship 1 to many JPA?
I’m using JPA with Spring Framework on a project, I would like to limit a relationship 1:n, want to do 1:5, how do I do that? This is the relationship: @ManyToOne private Task task;…
-
2
votes1
answer277
viewsSecond Level Cache - JPA and Eclipselink
I would like to totally disable the JPA/Eclipselink cache, but I’m not getting it. I can disable the first level cache using: query.setHint("javax.persistence.cache.storeMode",…
-
2
votes1
answer165
viewsHow to get the final JPA SQL using Namedqueries
How to get the SQL that is running by JPA when we use a createNamedQuery. I would like to have SQL run to understand where the query problem is below: Call from the Namequery EntityManager em =…
-
2
votes0
answers157
viewsJPA + Eclipselink - Lazy Loading with closed Entitymanager
I am using Eclipselink as JPA preview in a Java SE project. I have correctly configured Weaving to allow Lazy Loading. Unlike Hibernate (which launches Lazyinitializationexception), Eclipselink…
-
2
votes2
answers236
viewsDatatable does not populate object? JSF
I have the following problem: I have a DataTable which is populated with entities of the type Login that belongs to Usuario as a relationship. A button called Add Login calls the method addLogin()…
-
2
votes1
answer58
viewsError creating database with Hibernate and Spring MVC
I have a problem running the application. Error... ERROR [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 58) Context initialization failed:…
-
2
votes0
answers34
viewsEmbeddable Hibernate Mapping
Good morning ! I have a question regarding composite key mapping. The situation is as follows: I have a class whose primary key of the same is composed of two other classes, but I have a third class…
-
2
votes1
answer1072
viewsNotes JPA @Onetomany or Manytoone?
I own the Report Class public class Report{ private String nome; @ManyToOne @JoinColumn( name = "idpai", referencedColumnName = "id" ) private List<Report> subReports getters e setters... } My…
-
2
votes1
answer1110
viewsHow do I return in json to Foreign key in Spring Boot?
As you can see it is returning to the cities without any problems in the following URL: http://localhost:8080/cidades, watch: This is a return coming straight from the database with a select * from…
-
2
votes1
answer550
viewsWildfly 11 does not recognize Mysql driver when deploying
I set up my Java Web project to use JTA when performing transactions with the Database. My project has 4 Maven modules, one is unique to model classes and the persistence layer. When I compile in…
-
2
votes1
answer111
viewsWhy doesn’t Entitymanager have the createQuery method with typed return?
I am following the project of the book Spring-MVC of Casa Do Código, using the latest version of Hibernate, a 4.0.3. But in a moment, when the book indicated the creation of a typed query through…
-
2
votes0
answers73
viewsProject error downloaded from github with Jboss 7.1.1
I downloaded a project from github (fj25-financas-web project - Caelum) and added this project to Jboss 7.1.1. When running, these errors occur: 16:07:15,515 ERROR [org.jboss.msc.service.fail] (MSC…
-
2
votes1
answer343
viewsIssues in netbeans with connection to Postgres
I have a bank called BANCO_DE_TESTES in Postgres that has some random tables. In netbeans when I try to use the Master Sample Form/Detail to use JPA to create a simple crud it doesn’t work saying…
-
2
votes0
answers155
viewsOne table is not being created - JPA/Hibernate with Mysql
I’m having a problem running my test class: import javax.persistence.EntityManager; import br.com.teste.jpa.c_mapeamento.model.Conta; public class PopulaConta { public static void main(String[]…
-
2
votes3
answers131
viewsMultiple query values with JPA/Sprint and Rest
Good morning, I need to make a query via REST where multiple ID will be sent for example (ID: 1, ID: 2, ID:3, etc). To search only for an ID I use findById(codigo), but I don’t know how to use…
-
2
votes1
answer529
views -
2
votes2
answers1712
viewsHow to name a Hibernate/JPA Constraint?
Using the class: @Entity public class Pessoa{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long idPessoa; @Column(nullable=false, unique = true) private String nome; @OneToOne…
-
2
votes1
answer27
viewsI’m hoping that clicking a jsf radio button with primefaces will disable an inputText
<p:inputText id="txtCidadeFora" value="#{moradorRuaBean.moradorRua.cidade}" disabled="#{moradorRuaBean.ishabilitaCidade == false}"></pmf:campoTexto> Could someone help me? In managedBean…
-
2
votes1
answer740
viewsHow to make Hibernate read a table in a Mysql database and write to another table in Postgresql?
I need to consult a database in Mysql and take a table from there to write to a database in Postgresql by Hibernate/JPA. I set up the persistence.xml as follows: <?xml version="1.0"…
-
2
votes1
answer4566
viewsHow do I resolve the "No Persistence Provider for Entitymanager named" error?
When I try to execute the method Persistence.createEntityManagerFactory("Aluno") class Persistence i get the following error: run: abr 04, 2016 9:11:30 PM org.hibernate.ejb.HibernatePersistence…
-
2
votes6
answers2011
viewsHibernate is not creating the tables
I am new to the subject Hibernate, for the little I have learned, I believe I did everything right, ie, I lowered the dependencies, I wrote down the classes, etc. Below follows my class example:…
-
2
votes1
answer105
viewsEntity Repository Spring Error with Relationships
I have a project using Spring Boot to serve JSON on a Webservice. An error occurred when adding the Repository class. If you remove it the program starts normally (no errors in the console, I don’t…
-
2
votes1
answer500
viewsCalculated Field JPA Spring Boot
I’d like help finding a calculated field. The problem is that it involves relationships. I need to calculate the total of a Sale with various Sales Items (products). Partial total per Item of Sale…
-
2
votes2
answers2921
viewsHow to resolve JPA Hibernate error
You can help me with this mistake? Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named bsewebservicePU at…
-
2
votes1
answer397
views@Onetomany without Primary Key
There is the possibility of making a relationship @OneToMany without Primary Key on the daughter table? Follow my two entities. Entity Noticia: @Entity @Table(name = "NOTICIA") @NamedQueries({…
-
2
votes1
answer485
viewsCreate JPA project without persistence.xml?
I created a project with Swing and JPA and is working well, now I want to remove the file persistence.xml and create a class for him to work in his place. I’m researching some way to do this and I…
-
2
votes1
answer265
views -
2
votes0
answers287
viewsJSF + Wildfly multi-bank connection dynamically
Hello, I have a web application using JSF + CDI + JPA and Wildfly 8 as the application server. So far I’m letting the server manage transactions, where the connection information with the database,…
-
2
votes1
answer41
viewsHelp with Broken pipe
Guys, I have a problem in my system, it is falling too much the connection as database, this system gets to 12 hours idle, I need a help to configure C3P <!--Configuração do pool de c3p0 -->…
-
2
votes0
answers197
viewsHibernate JPA locks
When you run persistence to create tables in the database netbeans hangs the exits on this item Oct 26, 2016 3:11:05 pm org.hibernate.dialect.Dialect INFO: HHH000400: Using dialect:…
-
2
votes2
answers1050
viewsAnnotation problem for mapping
I’m having errors due to my mapping to my java program, I’m still starting to mess with Annotation (I ask you to forgive possible stupid xD errors). Error must be on @Manytoone/Onetomany... I have…
-
2
votes2
answers333
viewsDelete data with the @Manytoone interface
How do I delete data with the interface @ManyToOne? It does not give error, but does not erase the data in the database. My class Pedido: public class Pedido extends GenericDomain{ @Column(nullable…
-
2
votes1
answer365
viewsWhat is Optimistic JPA Locking Field
What is and what is the "Optimistic Locking Field" of JPA? I noticed that there is this option for Eclipse Link and Hibernate and this function is enabled when annotating a version attribute within…
-
2
votes4
answers1921
viewsHibernate does not create table automatically in mysql
I’m studying Spring with a little hibernate, where I stopped in a situation I can’t pass. I configured the code with Hibernate for creating tables in the database but when I run the application it…
-
2
votes3
answers572
viewsHow to map an entity with a composite key using JPA?
@Entity @Table(name = "USUARIO") public class Usuario implements Serializable { @Id @GeneratedValue(strategy= GenerationType.AUTO) @Column(name = "ID") private Long id; @Column(name = "USER_NAME",…
-
2
votes0
answers340
viewsSelect * from Table and No Select * from Entityname - JPA JAVA
My query was built like this, but when it does the request: @Query(value = "SELECT CT.id FROM CursoTurno AS CT LEFT JOIN Curso AS C ON C.id = CT.curso_id INNER JOIN Turno AS T ON T.id = CT.turno_id…
-
2
votes1
answer121
viewsData persistence problem using JPA
I have a class that has two attributes, start time and end time, both Date type. @Temporal(TemporalType.TIME) private Date horarioInicio; @Temporal(TemporalType.TIME) private Date horarioFinal; In…
-
2
votes1
answer313
viewsProblems with JPA, @Onetoone and mappedBy
I have three classes, Person, Client and Address, being Customer Person’s child and Address adding Person. Segue Pessoa: @Entity public abstract class Pessoa implements Serializable { private static…
-
2
votes0
answers78
viewsInject EJB in Bean Spring
I’m working on a Java EE + Primefaces + JPA project with EJB. In the authentication part I decided to use Spring Security, but I’m having a hard time getting the EJB inside the Spring controller. I…
-
2
votes1
answer1100
viewsPerform a date search in a timestamp column using spring data
I am trying to perform a search only for the current date in a column timestamp, or without giving the time and yes only the date. Model: @DateTimeFormat(pattern = "dd/MM/yyyy hh:mm")…
-
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…