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
12
votes
1 answer

How to use JPA 2.1 property javax.persistence.schema-generation.database.action?

Allowed values for javax.persistence.schema-generation.database.action are none (that doesn't serve anything...) create (which only works the first time the application is started because all further starts fail due to most databases (e.g. derby…
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
11
votes
3 answers

Koitlin support for JPA static metamodel

When I create an Entity class using Java JPA static meta models are generated. If I convert my Entities to Kotlin JPA static metamodels are not generated. How to solve this problem? EDIT I am using Gradle as build tool.
A0__oN
  • 8,740
  • 6
  • 40
  • 61
11
votes
2 answers

Spring JPA Specifications Not In Query

Here the IN criteria query using Spring JPA Specification is working fine. but I don't know how to use "NOT IN".. So How can i use the NOT IN criteria query using Spring JPA Specifications. SearchSpecification spec = new…
11
votes
4 answers

JPA 2.1: Introducing Java 8 Date/Time API

I'd like to add support for the Java 8 Date/Time API (JSR-310) in my JPA-enabled application. It's clear that JPA 2.1 does not support the Java 8 Date/Time API. As a workaround, the most common advise is to use an AttributeConverter. In my existing…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
11
votes
2 answers

Jpa - Hibernate ManyToMany do many insert into join table

I have follows ManyToMany relationship between WorkDay(has annotation ManyToMany) and Event WorkDay entity @Entity @Table(name = "WORK_DAY", uniqueConstraints = { @UniqueConstraint(columnNames = { "WORKER_ID", "DAY_ID" }) }) @NamedQueries({ …
HAYMbl4
  • 1,450
  • 2
  • 15
  • 29
11
votes
0 answers

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 Employee entity: @Entity @Table(name = "employee",…
edmallia
  • 203
  • 2
  • 9
11
votes
3 answers

@ConstructorResult with Enum in JPA 2.1

I am not having any idea how to use Enum in @ColumnResult Type while using @ConstructorResult of @SqlResultSetMapping @SqlResultSetMapping(name="DetailAndResult", classes={ …
Vik
  • 125
  • 1
  • 9
11
votes
2 answers

@Converter annotated class not getting auto detected by jpa

@Converter(introduced since JPA2.1) seems to be a very handy way to switch database values to the value we want to see in our java code. However, I am unable to get this thing working. JPA seems to be unaware to the converter I have written and is…
azi
  • 929
  • 1
  • 11
  • 31
10
votes
1 answer

Setting up custom scheme using @DataJpaTest

I want to test a Repository with Spring Boot and want to include TestEntityManager to check that the repository really does what it should do. That's the JUnit Test: @RunWith(SpringRunner.class) @DataJpaTest public class MyRepositoryTest { …
Nina
  • 681
  • 1
  • 10
  • 27
10
votes
2 answers

update existing column value in JPA CriteriaUpdate

i have an Entity User, and my DB value for user is: name totalScore -------------------- ABC 25 XYZ 30 Now i want to run the query update user set totalScore=totalScore+ (2*totalScore); How can we achive it through JPA 2.1…
Ashish Ratan
  • 2,838
  • 1
  • 24
  • 50
10
votes
4 answers

What is the best way to bulk delete rows in JPA while also cascading the delete to child records

I'm trying to do bulk delete in my entities, and the best solution will be to go with CriteriaDelete. But CriteriaDelete does not cascade (at least not for me). So, it seems like the only solution which I have is to do select first and delete each…
user902383
  • 8,420
  • 8
  • 43
  • 63
10
votes
1 answer

Generate DDL script at MAVEN build with Hibernate4 / JPA 2.1

It seems like the hibernate3-maven-plugin used to generate DDL create/drop scripts is not compatible any more with Hibernate 4.3 and newer versions (using JPA 2.1). I use this plugin configuration :
Donatello
  • 3,486
  • 3
  • 32
  • 38
9
votes
1 answer

Add WHERE IN clause to JPA Specification

I'm trying to implement search functionality limited by IN clause: I want to implement search implementation with filter limitation: @GetMapping("find") public Page getAllBySpecification( @And({ …
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
9
votes
1 answer

How to map ONE-TO-MANY native query result into a POJO class using @SqlResultSetMapping

Im working in a backend API using Java and MySql, and I'm trying to use @SqlResultSetMapping in JPA 2.1 for mapping a ONE-TO-MANY native query result into a POJO class, this is the native query: @NamedNativeQuery(name = "User.getAll”, query =…
Tamer Saleh
  • 473
  • 9
  • 21
9
votes
2 answers

JPA/Hibernate Multiple representations of the same entity

My Entities: @Entity public class Document { @Id protected String id; //It string in purpose @OneToOne(cascade = ALL) @JoinColumn(name = "DOCUMENT_DETAILS") private DocumentDetails details; } @Entity @Inheritance(strategy =…
Krzysztof
  • 1,861
  • 4
  • 22
  • 33
1
2
3
43 44