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

Entity with table possibly missing in some environments

I have an entity representing generic users, stored in a table that is filled only on lower environments. Of course, that shouldn't be used in production, and to be sure we don't make a mistake, the mock table even doesn't exist in production…
huartgi
  • 61
  • 1
  • 5
0
votes
0 answers

Additional query was run though it is not part of the select statement

I have created two Entity Java file which indicate there are two tables, User and UserPasswordHistory, UserPasswordHistory has ManyToOne Relationship to user table, whenever i select UserPasswordHistory by the foreign key userid, it will select the…
chunghow
  • 21
  • 2
0
votes
0 answers

JPA one-to-one mapping

I am not able to create one-to-one relation JPA. When I run the program, I am getting following error: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AI" and "Latin1_General_BIN" in the equal to operation. @Entity …
0
votes
0 answers

JPA Replace Business key with Primary Key

I'm working with a legacy database. I'm using JPA 2.x I have : a table BUSINESS_ORDER containing domain objects with a PK + a Natural Business Key a table BUSINESS_LEDGER containing domain objects with a PK + a Composite Natural Business Key a…
Archange
  • 397
  • 5
  • 21
0
votes
1 answer

Is it possible to disable automatic schema evolution when using JPA?

Let's say that i have the two Entities below : @Entity public class Employee { String name; @ManyToOne Department department; } @Entity public class Department { // persisted flieds ... @OneToMany(mappedBy="department") Collection
user771221
  • 127
  • 9
0
votes
0 answers

Call MS SQL Function from JPA

I have a function in MS SQL like: CREATE FUNCTION FOO (@param1 int,@param2 int) RETURNS table AS RETURN (SELECT a, b, c FROM MyTable WHERE p = @param1 AND (@param2 IS NULL OR x =…
Moki
  • 21
  • 3
0
votes
2 answers

Convert Spring's Order to JPA Order from Pageable

Our frontend is designed to send Pageable object with Spring's Order which contains attribute name. Sample Entity: @Entity @Table public class Foo { private String userName; @Embedded private Bar bar; } @Embeddable public class Bar { …
Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174
0
votes
1 answer

Left Outer Join in Criteria Api

I'm trying to get the following query using the Criteria API: select lang.* from LKUP_LANG lang LEFT OUTER JOIN LANG_SEQUENCES seq ON lang.SHORT_NAME=seq.LANG_CODE and (lang.DISPLAY_NAME is not null) order by nvl(seq.SEQ_LANG_CODE, 2147483647)…
Gaurav Goenka
  • 152
  • 12
0
votes
1 answer

Implement JPA query with COUNT and SUM

I want to implement JPA query using this SQL query: String hql = "SELECT DATE(date) AS Date, SUM(volume) AS amount, COUNT(*) AS number_of_transactions " + " FROM " + PaymentTransactionsDailyFacts.class.getName() + " WHERE (date…
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
0
votes
1 answer

CriteriaBuilder: Create Criteria based on DataType at runtime

I have a simplified Entity class like this: @Entity public class Student { String name; Date birthday; Integer term; } A third party dependency (DataTables) is sending a search request in form of a Map where the key is…
Thanthla
  • 526
  • 1
  • 8
  • 29
0
votes
1 answer

How to fetch an entity having a timestamp property that is within an hour from other timestamp property with JPA and Hibernate

I have a doubt in JPA query criteria builder with path or expression. I want to find who are all entered first post comment with in an hour after their  account created Path accountCreatedTime = root.
Ram
  • 37
  • 4
0
votes
0 answers

JPA - No link between my object and the database

I try to persist an object in postgres database. After the persist call, I return my object, I modify my object, research the object (with function find of my entity manager) and data is still the same (before my object's modification). I believe…
GGENIER
  • 1
  • 3
0
votes
0 answers

Persisting future changes temporarily before applying them with JPA/Hibernate 5+

I need to create a model in which changes to entities (essentially a transaction) need to be persisted separately and go through a process of approval (by other users) before being actually applied. Think of it as creating a branch in Git…
Learner
  • 1,215
  • 1
  • 11
  • 26
0
votes
1 answer

native query issues

I'd like to create a criteria query, where I can set different entity properties and different values depending on method args. public List searchBar(String entityProperty, String value) { String nativeQuery = "SELECT * FROM devices…
Tiago
  • 5
  • 3
0
votes
0 answers

Deltaspike repository transaction commits but nothing persists in DB in Java SE

I'm using DeltaSpike repositories to persist an entity in Java SE and I'm using file based H2 database. The problem is that while there is no error in the console, nothing gets persisted in the database. I checked the database contents using an…
zaerymoghaddam
  • 3,037
  • 1
  • 27
  • 33