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
5
votes
3 answers

Adding the JPA @OrderColumn afterwards causes null index column for collection error

Let's say, we have an @OneToMany relation for entities A and B. Each A can have many B. @Entity public class A{ @Id private long id; ... @OneToMany(mappedBy="ref") private List items; ... } @Entity public class B{ @Id private…
ilhami visne
  • 305
  • 5
  • 13
5
votes
2 answers

Hibernate with Glassfish 4.1

I've setted up Hibernate on Glassfish 4.1 but I'm having problems with persistence. I'm able to read data, but cannot write to BD (changes appear to not be commited). My current persistent.xml looks like this:
martins.tuga
  • 1,662
  • 1
  • 16
  • 20
5
votes
2 answers

Where can I get complete set of javax.persistence properties

Where can I get complete set of javax.persistence properties. which I can use in persistence.xml in JPA 2.1. I have tried more that half a day. I have got only few properties from JPA specification and remaining properties are vendor specific. But I…
Jagadeesh
  • 862
  • 7
  • 23
5
votes
1 answer

JPA 2.1 NamedSubgraph in Hibernate ignoring subclasses

I'm using Hibernate 4.3.8.FINAL and have the following model where a Department has many Employees, and an Employee can be a Manager. The Employee entity: @Entity @Table(name = "employee", schema = "payroll") @Inheritance(strategy =…
edmallia
  • 203
  • 2
  • 9
5
votes
1 answer

Filter full text search results by userId field with hibernate

Suppose I have 2 entities annotated for full text search: @Entity public class User implements Serializable { @Id public Long id; ... } @Entity @Indexed public class Post { @Id public Long id; @Field(name =…
user1079877
  • 9,008
  • 4
  • 43
  • 54
5
votes
4 answers

Registering Converters in JPA 2.1 with EclipseLink

On JavaEE environment, I use JPA 2.1 implementation with EclipseLink, I have some entities that contain enums. So I have created converters for these enumerations. Car entity : @Entity public class Car implements Serializable { private static…
user1079425
5
votes
3 answers

JPA Criteria Query with predicate that compares a field annotated @Convert gets a ORA-00932 upon execution

I'm developing a Java EE 7 application (persistence provider is Hibernate 4.3.5, DB is Oracle 11g) in which I'm using a entity class with a Long field that represents the millis of a date. It's been done that way to avoid the problems of using DBs'…
jpangamarca
  • 713
  • 2
  • 13
  • 33
5
votes
1 answer

JPA 2.1 Type Converter doesn't get executed on NULL values

I'm testing the new JPA 2.1 Type Converters. I want to avoid NULL String values to be stored in a legacy database as they are not allowed. So I defined the following converter: @Converter(autoApply=true) public class CString implements…
Manuel Z
  • 51
  • 1
  • 2
5
votes
1 answer

JPA 2.1 Foreign Key isn't saving on ManyToOne cascade

I have two classes. public class Reservation { @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true, mappedBy = "reservation") private List nights; \\assume getters and setters } public class Night { @ManyToOne …
Risu
  • 796
  • 2
  • 14
  • 26
5
votes
0 answers

Delete from many-to-many relationships using criteria in JPA 2.1

I'm using EclipseLink 2.5.1 (and Hibernate 4.3.5 final) having JPA 2.1. Given the following tables in MySQL. product prod_colour (join table) colour There is a many-to-many relationship between products and their colours. A product can have many…
Tiny
  • 27,221
  • 105
  • 339
  • 599
5
votes
1 answer

Hibernate 4 Wildfly 8 logging not working

How do I get hibernate 4 to log via logback? I have a war deployed to wildfly 8 final, and I am using slf4j with logback. The logging setup is working 100% in the application with both the console appender and file appender working as intended. Here…
Sphynx
  • 492
  • 5
  • 13
5
votes
1 answer

Schema generation with EclipseLink and Hibernate (JPA2.1) - @ForeignKey ignored

I am testing JPA2.1 and the new "schema generation" feature. For that, I tested two implementations under the HyperSQL database : EclipseLink 2.5.2-M1 which is the reference implementation. Hibernate 4.3 I don't have any preference for an…
NoDataFound
  • 11,381
  • 33
  • 59
4
votes
2 answers

How to generate the data schema with Hibernate on PostgreSQL 13

I am working on a new project with postgreSQL 13 and the auto generation of the data schema does not work. My approach is to use annotations on my entities as I always did before. Here is one of my entities and my persistence.xml…
4
votes
2 answers

QuerySyntaxException: expecting CLOSE, found '.'

I want to rewrite this SQL query into JPQL and use JPA Projection: SELECT count(id) as count, status, error_class, error_message, id, settlement_status_raw FROM `payment_transactions` WHERE `payment_transactions`.`terminal_id` = 16 AND…
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
4
votes
1 answer

Why is the MappedSuperClass annotation no longer valid in combination with @Inheritance when migrating to Hibernate 5.4.x?

I'm migrating several code bases to use Hibernate 5.4.x instead of Hibernate 5.2.x. For an abstract base class I use @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class AbstractPersistentJPAObject…
MWiesner
  • 8,868
  • 11
  • 36
  • 70