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 2.1 persist string as enum postgres

I am using JPA 2.1 to perform CRUD operations on my DB. I generated entities from a pre-existing DB using JPA Tools -> Generate entities from Tables option. This created a Java entity named Item. The DB table Item has a column of type enum…
0
votes
0 answers

Convert Oracle USING Query to JPA or JPQL?

How to convert below query to Spring Data JPA or JPQL query ? SELECT * FROM ACCT_PRCSS_DATA JOIN ACC_CUST_MSTR USING (ACC_NUM); I tried below @Query(value = "SELECT e FROM EdsPrcssData e JOIN ", nativeQuery = true) List
Jeff Cook
  • 7,956
  • 36
  • 115
  • 186
0
votes
0 answers

An association field cannot be used in an update item's path expression Spring Data JPA

I am using Spring Data JPA and JPQL query. When trying to execute the below update query, getting the below error. How we can solved this problems? Query: @Query("UPDATE EmployeeSrc e SET e.employeeStat.employeeStatStatCd =?1, e.UpdtDt =?2,…
Jeff Cook
  • 7,956
  • 36
  • 115
  • 186
0
votes
0 answers

JPA 2.1 Timestamp type field for versioning and optimistic locking always throwing OptimisticLockException

Environment: JPA 2.1, EclipseLink 2.6.3, SQL Server 2016 I want to use a field of type Timestamp for versioning and optimistic. I do not have option to use numeric column for versioning. My understanding is I just need to annotate the field with…
0
votes
0 answers

Eclipse Photon with JPA: import javax.persistence can not be resolved

I installed GlassFish 5 and GlassFish Tools (from http://download.eclipse.org/glassfish-tools/1.0.0/repository/). I also tried with GlassFish 4.1.1, results were the same. I created a new JPA Project (JPA 2.1): In Data Source Explorer View of…
Markus
  • 578
  • 6
  • 26
0
votes
0 answers

How to Generate JPA Metamodel classes? (July 2018)

I have a maven/hibernate/mysql app I'm developing and am having an issue getting the jpa-metamodel stuff working. I have this in my pom.xml: org.hibernate hibernate-core
badperson
  • 1,554
  • 3
  • 19
  • 41
0
votes
0 answers

Using CriteriaDelete for delete operations

I'm using JPA Criteria API, and I want to remove "Actions" that have "Loop" is equal to the passed param, so I did as following: public void removeByLoopId(final Long id) { CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); …
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
0
votes
2 answers

How to use JPA query to retrieve parent and last child entity

I have 2 tables say Parent and Child and they are one-to-many relationships. In the entity classes, the Parent class has a list of Child objects. So if using JPA query, how can I write a query to retrieve all Parent(s) and their last child? There…
Dicky Ho
  • 35
  • 6
0
votes
1 answer

Generate 'woven entity classes' automatically

I'm working with Spring-Data-JPA and EclipseLink. In order to do static weaving of my entity classes I have defined my pom with: org.codehaus.mojo exec-maven-plugin
Eduardo
  • 1,169
  • 5
  • 21
  • 56
0
votes
1 answer

Not able to generate entities on JPA project with SQL server connection

When i tried to generate entities form tables on eclipse i see below error. I tried multiple java version as 9 and 10 also tried with different versions of jdbc jars but never got resolved. Below are the eclipse logs: !MESSAGE Error Generating…
0
votes
0 answers

EclipseLink JPA 2.1 - Exception thrown when calling JPA native query and try to map the result to POJO

I am using EclipseLink 2.5.2 and is using the following orm.xml to map the result of native query to POJOs. select item_file_name , last_release_id ,…
Dicky Ho
  • 35
  • 6
0
votes
1 answer

Criteria api fetch object from ancestor

is there any change to fetch object from ancestor? I have these entities: @Entity @Table(name = "SPORT") @DiscriminatorColumn(name = "sport_type", discriminatorType = DiscriminatorType.STRING, length = 32) @Inheritance(strategy =…
user1604064
  • 809
  • 1
  • 9
  • 29
0
votes
1 answer

JPA property access isMethod

JPA property access: getter and setter. Does it support isMethod for boolean? For example, @Entity @Access(AccessType.PROPERTY) public class Foo { private boolean closed; public boolean isClosed() { return this.closed; …
eastwater
  • 4,624
  • 9
  • 49
  • 118
0
votes
1 answer

Changes not reflected after "refreshing" entity with Spring JPA

I'm strugglingtrying to "refresh" an entity (Foo) that look like this: public class Foo { //... @OneToMany(mappedBy = "fooRef", fetch = FetchType.LAZY) private List bars; } public class Bar { //... @Column(name =…
anat0lius
  • 2,145
  • 6
  • 33
  • 60
0
votes
1 answer

How to map different country/state codes to a base entity via JPA annotations?

I have an entity with the following fields: private Date dateOfBirth; private String cityOfBirth; private Long birthStateCodeId; private Long birthCountryCodeId; private Boolean isUSCitizen; private Long citizenshipCountryCodeId; private String…
Sunil Kosuri
  • 99
  • 1
  • 15