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
7
votes
2 answers

unexpected token: LIMIT

I am getting an error mention in ERROR section when using the mentioned dependency with NamedQuery. Note: please suggest, is it a jar problem or JBOSS? I am running this code in Jboss 7 version with jdk1.7. Named query used using…
Uday kumar
  • 81
  • 1
  • 1
  • 5
7
votes
1 answer

Hibernate index with DESC order

is there a way to create multicolumn index with one column with DESC order? I've tried this (annotations from javax.persistence package): @Table(name = some_table indexes = { @Index(name = "idx_multi_column", columnList = "column1, column2,…
viliam
  • 503
  • 6
  • 23
7
votes
1 answer

How to use Constructor Mapping with Spring JPA Repositories

I have a Spring repository as follows: import org.springframework.data.repository.Repository; import org.springframework.stereotype.Component; import com.test.domain.My; @Component public interface MyRepository extends Repository { …
James
  • 2,876
  • 18
  • 72
  • 116
7
votes
2 answers

Prevent duplicate entries in a join table in a many-to-many relationship in JPA

I'm using EclipseLink 2.5.1 (and Hibernate 4.3.5 final). Given the following tables in MySQL. product prod_colour (join table) colour There is a many-to-many relationship between products and their colours. A product can have many colours and a…
Tiny
  • 27,221
  • 105
  • 339
  • 599
7
votes
3 answers

JPA 2.1/Hibernate 4.3 deprecation warning

I'm using JPA 2.1 sample application with Hibernate 4.3.x implementation.
Ashot Karakhanyan
  • 2,804
  • 3
  • 23
  • 28
6
votes
1 answer

JPA - Persist @Temporal LocalDate using a converter

Unable to compile code using @Temporal for LocalDate. Entity code ... @Temporal(TemporalType.DATE) private LocalDate creationDate; public LocalDate getCreationDate() { return this.creationDate; } public void setCreationDate(LocalDate…
user1418717
  • 425
  • 2
  • 5
  • 13
6
votes
1 answer

how to add entity listener programmable in Hibernate JPA

I use spring, hibernate, jpa2.1. as follow: @Entity @EntityListeners(DemoListener.class) public class Demo { @Id private Long id; public Long getId() { return id; } public void setId(Long id) { this.id = id; …
peacetrue
  • 186
  • 1
  • 15
6
votes
2 answers

JPA @SqlResultSetMapping not able to handle empty sql result to be mapped to empty POJO - instead an exception is thrown

I'm using JPA 2.1 (Eclipselink vendor) @SqlResultSetMapping to map sql query to none Entity POJO, it works when the sql result is not empty, but when the my table is empty the construction of my POJO fails with the exception : 2016-05-30…
Elia Rohana
  • 326
  • 3
  • 16
6
votes
2 answers

with-clause not allowed on fetched associations

I have a name query like the one below - but keep getting an error from Hibernate that it will not allow my 'with'-clause since I'm doing join fetch. I need to do join fetch - because it there is a related item then I wan't it to be present on the…
6
votes
1 answer

Criteria API and Entity Graph

I have two entities with unidirectional lazy relations. And one of them has a named entity graph. Here are the entities (getters and setter are not listed due to readability): @Entity @NamedEntityGraph ( name = "Sms.fetchSims", …
Wyvie
  • 140
  • 1
  • 6
6
votes
4 answers

How do I write a JPA 2.1 update criteria query without joins?

I’m using JPA 2.1, Hibernate 4.3.6.Final, and MySQL 5.5.37. I’m trying to use the CriteriaBuilder API to write an update query that will update multiple rows. However, I’m getting an “java.lang.IllegalArgumentException: UPDATE/DELETE criteria…
Dave
  • 15,639
  • 133
  • 442
  • 830
6
votes
0 answers

JPA: Why GenerationType.AUTO could not be used with InheritanceType.TABLE_PER_CLASS strategy

Could somebody explain why InheritanceType.TABLE_PER_CLASS could not use the GenerationType.AUTO strategy for primary key value generation when mapping inheritance?
skip
  • 12,193
  • 32
  • 113
  • 153
5
votes
1 answer

"Ordinal binding and Named binding" issue when calling Stored Procedure with Jpa 2.1

Using: Spring Boot 1.4.0.RELEASE JPA : 2.1 Hibernate : 5.0.9 Hibernate Dialect : org.hibernate.dialect.Oracle10gDialect Oracle Database : 12.1.0.2 Oracle JDBC: ojdbc7 12.1.3-0-0 In essence, when I try to execute a Stored Procedure, I'm faced with…
demaniak
  • 3,716
  • 1
  • 29
  • 34
5
votes
0 answers

Calling stored procedure with JPA - pass a custom object

I have a procedure on Oracle database: TYPE r_age IS RECORD (id VARCHAR2(100), min VARCHAR2(100), max VARCHAR2(100)); TYPE t_ages IS TABLE OF r_age INDEX BY BINARY_INTEGER; PROCEDURE synchronize_ages…
5
votes
2 answers

JPA 2.1 is not generating schema scripts

I started JPA 2.1 with Hibernate, and had the following lines in my persistence.xml
VHanded
  • 2,079
  • 4
  • 30
  • 55