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

org.hibernate.QueryException: illegal attempt to dereference collection

I am trying following hql query to execute SELECT count(*) FROM BillDetails as bd WHERE bd.billProductSet.product.id = 1002 AND bd.client.id = 1 But it is showing org.hibernate.QueryException: illegal attempt to dereference…
xrcwrn
  • 5,339
  • 17
  • 68
  • 129
63
votes
7 answers

JPA Query selecting only specific columns without using Criteria Query?

Is it possible to select, say, only properties A and B from an object using a JPA query without using criteria queries? To select all properties I'd just do something like: SELECT i FROM ObjectName i WHERE i.id = 10 But I have an object with many…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
60
votes
1 answer

How to specify JPA 2.1 in persistence.xml?

A quick search on the Net reveals three or four variants how folks have been specifying xmlns and xsi:schemaLocation in persistence.xml. What would be the 'correct' manner to specify JPA version 2.1? I'm using
kmansoor
  • 4,265
  • 9
  • 52
  • 95
58
votes
8 answers

JPA support for Java 8 new date and time API

I'm using Java 8 for my new project. I'm trying to use new date and time api in java 8 however I don't know if JPA 2.1 fully supports this new Date and Time API or not. Please share your experience/opinion in JPA`s supports for new date and time API…
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125
37
votes
4 answers

Getting error Could not locate appropriate constructor on class

I am trying to map native SQL result to my POJO. Here is the configuration. I am using spring.
Basit
  • 8,426
  • 46
  • 116
  • 196
35
votes
3 answers

Named Entity Graph Sub-Subgraph

I am new to JPA 2.1 and started using only recently Named Entity Graphs. For my project I am mapping the following relation in JPA 2.1: Order -> OrderDetail -> Product -> ProductLine The question: I want to instruct JPA to join and fetch properly…
sashok_bg
  • 2,436
  • 1
  • 22
  • 33
30
votes
4 answers

Exclude JPA 2.0 from JBoss 7.1 in order to use hibernate 4.3

I want to use hibernate 4.3 for its multitenancy features in JBoss 7.1. I managed to include it in my war by adding the following lines in jboss-deployment-structure and adding a…
andreadi
  • 1,953
  • 1
  • 20
  • 35
23
votes
1 answer

Supported source version RELEASE_6 from annotation processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor less than source1.7

I have an enterprise application running in the following environment. Mojarra 2.2.7 PrimeFaces 5.0 final PrimeFaces Extension 2.0 final OmniFaces 1.8.1 EclipseLink 2.5.2 having JPA 2.1 GlashFish 4.0 NetBeans IDE 8.0 JDK 1.7 I have changed the…
Tiny
  • 27,221
  • 105
  • 339
  • 599
19
votes
2 answers

Hibernate HT_ Temporary Tables ON JOINED inheritance, Migration from Hibernate 3.4.0.GA To 5.1

I'm trying to migrate an application from Hibernate 3.4.0.GA to Hibernate 5.1, and after complete the required changes on java code, when I deploy the application I'm watching how Hibernate is trying to create HT_ tables (global temporary), one for…
Javier Toja
  • 1,630
  • 1
  • 14
  • 31
16
votes
2 answers

Hibernate fails to load JPA 2.1 Converter when loaded with spring-boot and spring-data-jpa

I have a custom converter for UUID to transfer it to a string instead a binary: package de.kaiserpfalzEdv.commons.jee.db; import javax.persistence.AttributeConverter; import javax.persistence.Converter; import java.util.UUID; @Converter(autoApply =…
klenkes74
  • 431
  • 3
  • 10
16
votes
9 answers

Passing List in spring data jpa native query

Using spring data JPA, I am trying to make this sort of query (it is more complex, this is a simple case) @Query(nativeQuery = true, value = "SELECT * FROM events WHERE typeId IN (?1)") List findEventsByType(List
Antonio Acevedo
  • 1,480
  • 3
  • 21
  • 39
15
votes
1 answer

What's the difference between fetchgraph and loadgraph in JPA 2.1?

How does javax.persistence.fetchgraph differ from javax.persistence.loadgraph when providing an EntityGraph hint to a JPA 2.1 query? The documentation isn't really clear.
Daryl Banttari
  • 546
  • 3
  • 9
14
votes
3 answers

JPA: java.lang.StackOverflowError on adding toString method in entity classes

Everything worked fine until I added toSting() in my entity classes. After which I start getting the following error in runtime: Exception in thread "main" java.lang.StackOverflowError at java.lang.AbstractStringBuilder.append(Unknown Source) …
skip
  • 12,193
  • 32
  • 113
  • 153
13
votes
1 answer

JPA SubGraph to define fetchtype of an embedded property

I have an entity Ride which embeds an embeddable "entity" Route. Route has a List property towns with ManyToMany relation, so it has fetchtype LAZY (and I don't want to use EAGER). So I want to define an NamedEntityGraph for the entity Ride, to load…
user3909622
12
votes
1 answer

JPA2 Criteria and Java 8 Date&Time API

I try to port a Java web application to the new Java 8 Date&Time API (using 'LocalDate' and 'LocalDateTime' types among others) In Java 7, java.util.Date could be used in JPA2 criteria API to filter result sets on dates. Typically one would do this…
Hubert Schumacher
  • 1,683
  • 1
  • 16
  • 25
1
2 3
43 44