Questions tagged [jpa-2.1]

This tag is for questions specifically about new features of version 2.1 of the Java Persistence API.

The Java Persistence API version 2.1 improves JPA 2.0 with features like bulk operations, stored procedure support and new JPQL keywords.

Main features included in JPA 2.1 is:

  • Converters - allowing custom code conversions between database and object types.
  • Criteria Update/Delete - allows bulk updates and deletes through the Criteria API.
  • Stored Procedures - allows queries to be defined for database stored procedures.
  • Schema Generation
  • Entity Graphs - allow partial or specified fetching or merging of objects.
  • JPQL/Criteria enhancements - arithmetic sub-queries, generic database functions, join ON clause, TREAT option.
659 questions
9
votes
0 answers

Hibernate not compliant with JPA's NamedStoredProcedureQuery in case of Multiple Result Sets

I have recently been trying to use the JPA 2.1 NamedStoredProcedureQuery annotation with multiple REF_CURSOR result sets, and thus far have been unsuccessful in my attempts to get this working with Hibernate version 5.1.3-FINAL and Oracle 11g (tried…
Taoufik Mohdit
  • 1,910
  • 3
  • 26
  • 39
9
votes
2 answers

@Converter annotated class not getting auto detected in spring-boot project

I am using spring-boot 1.2.2 with hibernate.version:4.3.6.Final for a simple operation and was using the @Converter for mapping java8 LocalDateTime field to timestamp. In my converter class, I used autoApply=true as below. @Converter(autoApply =…
Varesh
  • 1,648
  • 2
  • 14
  • 22
9
votes
2 answers

JPA & enum table (aka "the one true lookup table")

Problem In lack of a SQL enum type an unfortunately somewhat popular database design pattern seems to be to create one table for all enum values (thank you for the link, Nathan). I have seen many variations of this over the years, but the one that…
Tilo
  • 3,255
  • 26
  • 31
9
votes
2 answers

Creating converters based on multiple attributes in JPA 2.1

JPA 2.1 introduced type converters. I have found examples of converters based on a single entity attribute. Is it possible to create a type converter based on multiple entity attributes? Are there some examples?
cassiomolin
  • 124,154
  • 35
  • 280
  • 359
9
votes
3 answers

IN clause with a composite primary key in JPA criteria

I have a table named group_table in MySQL with only two columns user_group_id and group_id (both of them are of type VARCHAR). Both of these columns together form a composite primary key. I need to execute a statement using a sub-select IN() to…
Tiny
  • 27,221
  • 105
  • 339
  • 599
9
votes
4 answers

How do I exclude the JBoss provided javax.persistence module?

I’m using JBoss 7.1.3.Final. I want to package my own Hibernate 4.3.0.Final Jars and the JPA 2.1 spec JARs within my WAR. It is not an option to replace the hibernate (or any other) module in JBoss. How do I exclude the JPA 2.1 from my WAR? I…
Dave
  • 15,639
  • 133
  • 442
  • 830
8
votes
2 answers

Need Help : Caused by: java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "variable" is null

I am trying to upgrade my SpringBoot Version from 2.1.1 to 2.7.x ( 2.7.5){Java Version - 17}, When I try to Run my application , I am getting the following error message Caused by: java.lang.NullPointerException: Cannot invoke…
8
votes
1 answer

How to use JPA - EntityGraph to load only a subset of entity @Basic attributes?

I found this documentation about entity-graphs... after read it, it gave me the idea that you can used entity-graphs to retrieve only a subset of @Basic fields of a given entity (Until now, I have used entity-graphs to retrieve relationships…
Carlitos Way
  • 3,279
  • 20
  • 30
8
votes
1 answer

JPA 2.1 @SqlResultSetMapping binding inner class to targetclass

is it possible to map inner classes to the targetclass, if possible, how is it done ? I'm new to this @SqlResultSetMapping functionality: @SqlResultSetMapping( name = "EventSurveysMapping", classes = { …
Esteban Rincon
  • 2,040
  • 3
  • 27
  • 44
8
votes
0 answers

UnitOfWork()--java.lang.NullPointerException in eclipselink

There are two databases that I have to hit depending on the user request. So I have the entries in persistance.xmlas follows jdbc/DB1
wib
  • 425
  • 3
  • 17
8
votes
5 answers

Hibernate Envers fails with @Converter and AttributeConverter (JPA 2.1)

I am using Hibernate 4.3.4 with Envers, and MySql 5.6. Without a JPA 2.1 converter, the Party entity below fails at Configuration.buildSessionFactory() as it should, since Hibernate doesn't know what to do with the Name…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
8
votes
1 answer

Define @UniqueConstraint in @MappedSuperclass

I have a requirement in which many of my entities need a Long value and a @ManyToOne relationship with some other entity. This requirement can be easily achieved with a MappedSuperclass in the following way: @MappedSuperclass public class…
Diego Borda
  • 173
  • 1
  • 9
8
votes
2 answers

Envers: Unidirectional OneToMany without additional audit table?

The following database schema: Employee[EMP_ID (PK), name, salary] Phone[ID (PK), number_str, OWNER_ID (FK)] Employee_aud[EMP_ID (PK), REV (PK/FK), REVTYPE, name, salary] Phone_aud[ID (PK), REV (PK/FK), REVTYPE,…
Andreas Aumayr
  • 1,006
  • 1
  • 11
  • 17
7
votes
2 answers

UnknownEntityTypeException in Bean from Maven

I've been trying to refactor a java project, moving submodules into separate projects deployed to our internal maven repository (archiva). The classes from the submodules are the following: org.example.srv.DomainUser org.example.srv.DomainUserBean…
KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
7
votes
1 answer

how to left join two unrelated entities with JPA criteria api?

using JPA 2.1 and hibernate 5.1.x, this is possible with JPQL select s.lowerBound, l.status ... from Serie s left join Line l on s.lowerBound between l.lineStart and l.lineEnd how do i write this using Criteria api? i attempted this Root
kfc
  • 291
  • 7
  • 24
1 2
3
43 44