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.

20,250 questions with no upvoted or accepted answers
12 votes
2 answers
2k views

QueryException: ResultTransformer is not allowed for 'select new' queries

I have the following SpringData Repository Query: @Query("SELECT new com.mypackage.MobileCaseList(c.ident, concat(c.subtype, ' - ', c.contactName), c.type, coalesce(c.updateTimestamp,c....
Beat Jost's user avatar
  • 350
12 votes
0 answers
4k views

Hibernate entity filters with Spring data repositories

I'm attempting to use Hibernate 4's Entity level @Filter's with Spring data repositories inside of a Spring Boot project. My end goal is to implement a generic soft delete with something a bit more ...
francis's user avatar
  • 6,169
11 votes
0 answers
2k views

JpaTransactionManager transactions not used by Hibernate Session

I am working on a project that is using Spring framework (4.3.3.RELEASE) and Hibernate (5.2.3.Final) and I am starting to move to using Spring Data JPA. I have just migrated the ...
Piers Geyman's user avatar
11 votes
1 answer
3k views

How to map native sql results to oneToMany field with SqlResultSetMapping in JPA

For example, say I have the following database tables Building ----------- id name and Room ----------- id roomNo buildingId the Building Java class will look something like @Entity public class ...
duvo's user avatar
  • 1,674
11 votes
0 answers
2k views

JPA 2.1 NamedSubgraph in Hibernate ignoring nested subgraphs

I'm using Hibernate 4.3.8.FINAL and have the following model where a Department has many Employees, and an Employee can be a Manager. Manager has a set of Foo which can be either Foo or Bar. The ...
edmallia's user avatar
  • 203
11 votes
1 answer
13k views

Passing a list of values to a stored procedure using JPA 2.1 / Hibernate 4

I have a stored procedure that takes in a list of strings (and follows limitations on stored procedures, according to Hibernate docs): PROCEDURE count_active_esc(p_count OUT NUMBER, p_codes IN ...
Yuri's user avatar
  • 1,755
10 votes
0 answers
5k views

How to emulate "ON CONFLICT" PostgreSQL statement using JPQL

I need to convert PostgreSQL native queries to JPQL. How the following two SQL statements can be translated: INSERT INTO my_table (id, some_data) VALUES (?1,?2) ON CONFLICT (id) DO NOTHING; INSERT ...
Sergey's user avatar
  • 3,542
10 votes
2 answers
1k views

Unknown entity with Hibernate upgraded to 5.2.3 and above

As soon as I upgrade to Hibernate 5.2.3 or above, Gradle isn't able to find my Entity Classes anymore: Caused by: java.lang.IllegalArgumentException: Unknown entity: data.model.User at org....
John Reese's user avatar
10 votes
2 answers
7k views

JPA with Hibernate 5: programmatically create EntityManagerFactory

This question is specifically about programmatically creating a JPA EntityManagerFactory backed by Hibernate 5, meaning without configuration xml files and without using Spring. Also, this question ...
Mike Nakis's user avatar
  • 59.4k
10 votes
1 answer
5k views

JPA: How to set MySQL session variables?

I need to set a mysql session variable for my application to work with a MariaDB Galera Cluster as expected. The SQL call is: SET SESSION wsrep_sync_wait = 1. It shall be set at all times when the ...
Hank's user avatar
  • 4,686
10 votes
1 answer
4k views

How do I construct a inverse join for a unidirectional relationship?

I guess this is easy, but I can't figure it out. If I have entities Foo and Bar: @Entity class Foo{ @OneToMany List<Bar> bars; } @Entity class Bar{ @Column int data; } and if I ...
Mihajlo Brankovic's user avatar
10 votes
2 answers
773 views

JPQL Constructor Expressions, how to eagerly fetch the main entity in 'select new'

The original query I have is somewhat complex, but what I'm trying to do is obtain the entity AlertCondition plus some additional fields. + " SELECT new org.rhq.core.domain.alert.composite....
user2687644's user avatar
10 votes
2 answers
841 views

Can Hibernate orphanRemoval work with unique constraints?

I have 2 entities: Role and Privilege. One role has many privileges. The entities look like this: @Entity public class Role { private Integer id; private String code; @OneToMany(mappedBy =...
yaskovdev's user avatar
  • 1,244
9 votes
1 answer
5k views

Unknown wrap conversion requested after migrating to spring boot 3

I am getting below exception for a jpa query org.springframework.orm.jpa.JpaSystemException: Unknown wrap conversion requested: java.util.ArrayList to java.lang.string: 'org.hibernate.type.descriptor....
Thejas's user avatar
  • 479
9 votes
1 answer
9k views

How to LOCK TABLE ... do stuff ... UNLOCK TABLE with Spring Boot?

The idea is basically to extend some Repositories with custom functionality. So I got this setup, which DOES work! @MappedSuperclass abstract class MyBaseEntity { @Id @GeneratedValue(strategy ...
TomGrill Games's user avatar

15 30 50 per page
1
2 3 4 5
1350