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

JPA/hibernate is generating the wrong SQL statement

My JpaRepository is generating the wrong SQL. It only updates shop and not the rest of the entity. After looking closer I noticed the query say update shop set nothing about campaign entity in which shop is inside. Inside Campaign there is a shop: …
Mike3355
  • 11,305
  • 24
  • 96
  • 184
0
votes
1 answer

Hibernate error with #new

I get this error with Hibernate 5.1 with JPA 2.1 on WildFly 12: Caused by: org.hibernate.PropertyNotFoundException: Could not locate setter method for property [rs.co.bora5.programs.sevid.model.Klijent#new] And i have implemented all getters…
0
votes
1 answer

Best JPA Inheritance option to implement the following requirement

Having the following kind of table tables. What will be the good approach to persist these tables? Used inheritance strategy for this, but it didn't work as expected. Requirement 1: Need to persist student table, it will persist the member as well…
0
votes
0 answers

Need help in writing a criteria query with JPA and Hibernate

Hi I am looking for JPA criteria query (Java code) for the following sql My SQL Query: SELECT @today := now(); select r.globalid, r.groupid from review r left join group ug on r.globalid = ug.globalid and r.groupid = ug.groupid --having problem…
Harry
  • 253
  • 1
  • 6
  • 19
0
votes
1 answer

Map new column from Spring Native query to entity

I have a case statement in my Native query where I am attempting to override a field in my entity. SELECT i.id, i.ONE_TO_ONE_ID, i.ANOTHER, CASE(WHEN condition THEN 'YES' WHEN another_condition THEN 'NO' ELSE 'MAYBE' END) as word .... I am using…
abarraford
  • 655
  • 2
  • 7
  • 23
0
votes
1 answer

How to map Map with a non-unique value set in JPA 2.1?

I'm trying to map a Map with a non-unique value set in JPA 2.1. The relationship can be uni-directional for now. There're a trillion explanations how to map a Map with a unique value set, but this question is not…
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
0
votes
1 answer

Why does 'EntityManager.contains(..)' return false even if an entity is contained in DB?

I used this JPA: check whether an entity object has been persisted or not to know if i persist or merge my entity , It will look like this : if (!getEntityManager().contains(entity)) { System.out.println(" PERSIST "); }…
Yagami Light
  • 1,756
  • 4
  • 19
  • 39
0
votes
1 answer

Wildfly 10 error with EntityListeners. Unable to build Hibernate SessionFactory - Argument resolvedBean must not be null

Environment: Wildfly 10.1.0 Java 9 I'm getting this error only by starting the project with a basic class and table. The connection details works from the test in the web server. Error when using javax.persistence.EntityListeners with Wildfly…
Joe
  • 7,749
  • 19
  • 60
  • 110
0
votes
2 answers

migrate glassfish JEE8 weapp to Wildfly10 (Jboss) - eclipseLink dont create database tables

I'm installing a open source project on jee8 security example in wildfly 10, because its working only in glassfish. My project source is there: https://github.com/robyp1/javaee8sec/ You can find configurations files and modules in…
robyp7
  • 481
  • 2
  • 7
  • 25
0
votes
1 answer

Application stopped working on Liberty 17.0.0.4 (works on 17.0.0.3)

I have a Java EE 7 application that works flawlessly on Liberty 17.0.0.3 - both locally and when running on IBM Cloud. But when I try to apply the same application on 17.0.0.4, I get the following error shown below. I see nothing in the release…
0
votes
1 answer

Hibernate & JPA 2.1 - mapping java.time.LocalDateTime as key in java.util.Map

The following enum is given from a domain model class: public enum OperationMode { BATTERY_CHANGE_MODE, PBP_MODE } I also defined a AttributeConverter to convert between LocalDateTime and TimeStamp @Converter public class…
0
votes
1 answer

criteriaBuilder selectCase in aggregate function throw QuerySyntaxException

I want to do a select case in a aggregate function but it throw a QuerySyntaxException : java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: case near line 1, column 125 : [select new…
ulquiorra
  • 931
  • 4
  • 19
  • 39
0
votes
0 answers

JPA 2.1 Left join on sub collection with filter of sub collection via 'on' clause

Given the following JPQL query: Select p, child, subChild from Entity parent p left join Child parent.children child left join SubChid child.subChildren subChild on subChild.field = 'value' I expect to have the parent entity with only child which…
Abbadon
  • 2,513
  • 3
  • 25
  • 33
0
votes
2 answers

No persistence error details seen using JPA 2.1

I have forced the error of sending a string higher than the maximum allowed in the table column, the trace when performing persist in the DB shows me a generic error, and I have not managed to know the exact error generated. I tried to get the cause…
HenRogTR
  • 13
  • 1
  • 6
0
votes
1 answer

Why an @ManyToMany should caused a NullPointerException?

I know that it could be too much vague but what could cause a NullPointerException after adding a @ManyToMany in my jpa entities? All code is the same, I deleted only the entity linked to the croos table and modified the two entities that before…
Filippo1980
  • 2,745
  • 5
  • 30
  • 44