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

How do joins in subquery root affect the result set of a JPQL or SQL query?

This may be a JPQL question or a SQL question, but since it came from a reading of a Criteria example in the JPA Spec. I'm tagging it JPA and Criteria API too. I think the problem is that I don't understand how SQL correlated subqueries work. Let…
Patrick Garner
  • 3,201
  • 6
  • 39
  • 58
0
votes
1 answer

Map two fields to one database column

Question: Am I somehow able to map two fields of my Entity class to only one Column in the Database? Scenario: The database is not fully normalized. There exists one Column which contains a composite information. It is not my actual use case, but an…
stg
  • 2,757
  • 2
  • 28
  • 55
0
votes
0 answers

EclipseLink: Predeployment of PersistenceUnit failed

I have a REST API Application in Java where I'm using EclipseLink. everything was OK, but after the code commiting I get this error when I want to run my app in my local machine. The error is: Exception Description: [class…
Jack Daniel
  • 2,397
  • 8
  • 33
  • 58
0
votes
0 answers

Eclipselink JPA support on wildfly 10.1

I have successfully ran eclipselink 2.6.2 on wildfly 10.0 But when I tried to migrate my application to wildfly 10.1 I got the following error. org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException: java.lang.IllegalArgumentException:…
Samy Omar
  • 800
  • 14
  • 29
0
votes
1 answer

JPAQL concat operation

I am trying to do following to get output like 'MASTHANVALI - Technical Writer' Query query = em.createQuery("select concat(upper(ename) , \" - \", deg )from employee"); But having following error. Exception in thread "main"…
0
votes
1 answer

JPA / eclipselink: join fetch all children annotated @OneToOne in one query

we try to join fetch data in one query but only the LocationAddress is join-fetched. for the LocationGeodata jpa always produces a second query. The @JoinFetch-Annotation in LocationAddress is not respected. given the following model and…
Steve
  • 384
  • 1
  • 7
  • 17
0
votes
1 answer

JPA 2.1 / Eclipselink: Reuse Criteria Queries as Named Queries

i am trying to reuse a dynamic query as a named query as described here: https://wiki.eclipse.org/EclipseLink/Release/2.5/JPA21#Add_Named_Query the goal is to build the criteria-query only once and then reuse it as a namedquery if parameter did not…
Steve
  • 384
  • 1
  • 7
  • 17
0
votes
1 answer

jpa: update relationship for a new parent-entity

i have two entities Price<-1----1->PriceDetail mapped as OneToOne. how can i handle different scenarios for this relation. so i have cases where i always want a new price and a new pricedetail, but i also would be able to create a new price only…
Steve
  • 384
  • 1
  • 7
  • 17
0
votes
0 answers

JPA "treat as" does not work

There is something wrong with my JPA 2.1 query but I don't understand what. I have the following entities: @Entity @Table public class DocumentEntity { @Id private Integer id; @OneToMany(mappedBy = "document", cascade =…
cheb1k4
  • 2,316
  • 7
  • 26
  • 39
0
votes
2 answers

Using JPA on startup singleton

I want to access database using JPA 2.1 eclipselink on startup. When it runs, I get login successful in the console log but it throws table or view does not exist. However, if I call my dao in servlet through rest service, everything runs fine. Am I…
SpyClown
  • 199
  • 1
  • 1
  • 14
0
votes
1 answer

org.hibernate.HibernateException [org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.]

I know that may that question has been asked before, but the difference for my question is that I am using extended PersistenceUnit and also I am not the one who manages the transaction as the server is responsible for managing it. BTW I am using…
mibrahim.iti
  • 1,928
  • 5
  • 22
  • 50
0
votes
1 answer

JPA retrieve certain fields from named query

I have the following entity (Person) with a relationship with @onetoone with (Direction) @Entity @Table(name="PERSON) class Person { ... @OneToOne @JoinColumn(name="DIRECTIONID",insertable = false, updatable = false) …
jcromanu
  • 1,171
  • 2
  • 13
  • 31
0
votes
1 answer

Criteria API JPA Hibernate: Distinct select on foreign key

Given is the following entity structure: @Entity public class Item { @Id @GeneratedValue private Long id; @OneToMany private Set itemEntries; public Item() { itemEntries = new HashSet<>(); } //…
fatdevelops
  • 435
  • 2
  • 6
  • 17
0
votes
1 answer

JPA. FetchType.Lazy caused strange behaviour @ManyToOne

I'm trying to improve the performance of a project that uses JPA. I'm using JPA 2.1 and Hibernate 5.0.1 implementation. I changed the FetchType of a ManyToOne relation to Lazy, so the thing blows up. When I just try to lookup all the records of…
BodaoZ
  • 15
  • 7