Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [jpa]

The Jakarta Persistence API (formerly Java Persistence API) (JPA) is a Java specification for accessing, persisting, and managing data between Java objects/classes and a relational database. JPA was defined as part of the EJB 3.0 specification as a replacement for the EJB 2 CMP Entity Beans specification. JPA is now considered the standard industry approach for Object to Relational Mapping (ORM) in the Java Industry.

85 votes
3 answers
94k views

Validation Error: Value is not valid

I have a problem with a p:selectOneMenu, no matter what I do I cannot get JSF to call the setter on the JPA entity. JSF validation fails with this message: form:location: Validation Error: Value is ...
klonq's user avatar
  • 3,547
42 votes
2 answers
34k views

JSF Controller, Service and DAO

I'm trying to get used to how JSF works with regards to accessing data (coming from a spring background) I'm creating a simple example that maintains a list of users, I have something like <h:...
PDStat's user avatar
  • 5,735
637 votes
9 answers
624k views

JPA JoinColumn vs mappedBy

What is the difference between: @Entity public class Company { @OneToMany(cascade = CascadeType.ALL , fetch = FetchType.LAZY) @JoinColumn(name = "companyIdRef", referencedColumnName ...
Mike's user avatar
  • 20.7k
1068 votes
16 answers
775k views

JPA EntityManager: Why use persist() over merge()?

EntityManager.merge() can insert new objects and update existing ones. Why would one want to use persist() (which can only create new objects)?
Aaron Digulla's user avatar
253 votes
12 answers
158k views

How can I make a JPA OneToOne relation lazy

In this application we are developing, we noticed that a view was particularly slow. I profiled the view and noticed that there was one query executed by hibernate which took 10 seconds even if there ...
KCL's user avatar
  • 6,763
349 votes
24 answers
721k views

PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate

I have a JPA-persisted object model that contains a many-to-one relationship: an Account has many Transactions. A Transaction has one Account. Here's a snippet of the code: @Entity public class ...
Paul Sanwald's user avatar
  • 11.2k
173 votes
33 answers
477k views

No Persistence provider for EntityManager named

I have my persistence.xml with the same name using TopLink under the META-INF directory. Then, I have my code calling it with: EntityManagerFactory emfdb = Persistence.createEntityManagerFactory("...
Robert A Henru's user avatar
905 votes
35 answers
1.1m views

How to fix the Hibernate "object references an unsaved transient instance - save the transient instance before flushing" error

I receive following error when I save the object using Hibernate object references an unsaved transient instance - save the transient instance before flushing
Tushar Ahirrao's user avatar
748 votes
18 answers
783k views

Difference between FetchType LAZY and EAGER in Java Persistence API?

What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API?
leon's user avatar
  • 10.3k
620 votes
18 answers
494k views

Hibernate throws MultipleBagFetchException - cannot simultaneously fetch multiple bags

Hibernate throws this exception during SessionFactory creation: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags This is my test case: Parent.java @...
blow's user avatar
  • 13.1k
312 votes
5 answers
538k views

How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?

I was working on my Spring boot app project and noticed that, sometimes there is a connection time out error to my Database on another server(SQL Server). This happens specially when I try to do some ...
METTAIBI's user avatar
  • 3,421
238 votes
23 answers
548k views

JPA : How to convert a native query result set to POJO class collection

I am using JPA in my project. I came to a query in which I need to make join operation on five tables. So I created a native query which returns five fields. Now I want to convert the result object ...
Gunjan Shah's user avatar
  • 5,118
24 votes
3 answers
56k views

Spring Data JPA - ZonedDateTime format for json serialization

I have a problem with the json serialization of ZonedDateTime. When converted to json it produces an enormous object and I don't want all that data to be transfered every time. So i tried to format it ...
Christos Baziotis's user avatar
243 votes
8 answers
450k views

How to map a composite key with JPA and Hibernate?

In this code, how to generate a Java class for the composite key (how to composite key in hibernate): create table Time ( levelStation int(15) not null, src varchar(100) not null, dst ...
kaaf's user avatar
  • 2,431
121 votes
8 answers
78k views

How to map an entity field whose name is a reserved word in JPA

@Column(name="open") Using sqlserver dialect with hibernate. [SchemaUpdate] Unsuccessful: create table auth_session (id numeric(19,0) identity not null, active tinyint null, creation_date datetime ...
TJR's user avatar
  • 3,743

15 30 50 per page
1
2 3 4 5
374