HHH-14837 - Move to Jakarta EE

preliminary transformation;
only `javax.persistence.*` settings supported atm
This commit is contained in:
Steve Ebersole 2021-09-22 17:52:06 -05:00
parent d43b9940b9
commit 089a3f86ae
5422 changed files with 24721 additions and 25479 deletions

View File

@ -22,16 +22,17 @@ buildscript {
plugins { plugins {
id 'org.hibernate.build.xjc-jakarta' version '1.0.2' apply false
id 'org.hibernate.matrix-test' version '3.1.1' apply false
id 'org.hibernate.orm.database-service' version '1.0.0-SNAPSHOT' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'nu.studer.credentials' version '2.1' id 'nu.studer.credentials' version '2.1'
id 'org.hibernate.orm.database-service' version '1.0.0-SNAPSHOT' apply false
id 'idea' id 'idea'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0' id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0'
id 'eclipse' id 'eclipse'
id 'org.hibernate.build.xjc' version '2.2.0' apply false
id 'org.hibernate.matrix-test' version '3.1.1' apply false
id 'biz.aQute.bnd' version '5.1.1' apply false id 'biz.aQute.bnd' version '5.1.1' apply false
} }

View File

@ -19,9 +19,10 @@ def projectsToIncludeInAggregatedJavadoc = [
':hibernate-c3p0', ':hibernate-c3p0',
':hibernate-graalvm', ':hibernate-graalvm',
':hibernate-hikaricp', ':hibernate-hikaricp',
':hibernate-jcache', // ':hibernate-jcache',
':hibernate-micrometer', ':hibernate-micrometer',
':hibernate-proxool', ':hibernate-proxool',
':hibernate-spatial',
':hibernate-vibur', ':hibernate-vibur',
':hibernate-gradle-plugin', ':hibernate-gradle-plugin',
':hibernate-enhance-maven-plugin', ':hibernate-enhance-maven-plugin',
@ -48,10 +49,8 @@ dependencies {
testImplementation project(':hibernate-testing') testImplementation project(':hibernate-testing')
testImplementation project(':hibernate-envers') testImplementation project(':hibernate-envers')
// todo (6.0) - add back hibernate-spatial dependency testImplementation project(':hibernate-spatial')
//testImplementation project(':hibernate-spatial') // testImplementation project( ':hibernate-jcache' )
testImplementation project( ':hibernate-jcache' )
testImplementation libraries.jcache
testImplementation project( path: ':hibernate-core', configuration: 'tests' ) testImplementation project( path: ':hibernate-core', configuration: 'tests' )
testImplementation 'org.apache.commons:commons-lang3:3.4' testImplementation 'org.apache.commons:commons-lang3:3.4'

View File

@ -36,9 +36,9 @@ public class Event {
---- ----
==== ====
The `@javax.persistence.Entity` annotation is used to mark a class as an entity. It functions the same as the The `@jakarta.persistence.Entity` annotation is used to mark a class as an entity. It functions the same as the
`<class/>` mapping element discussed in <<hibernate-gsg-tutorial-basic-mapping>>. Additionally the `<class/>` mapping element discussed in <<hibernate-gsg-tutorial-basic-mapping>>. Additionally the
`@javax.persistence.Table` annotation explicitly specifies the table name. Without this specification, the default `@jakarta.persistence.Table` annotation explicitly specifies the table name. Without this specification, the default
table name would be _EVENT_. table name would be _EVENT_.
@ -56,9 +56,9 @@ public Long getId() {
---- ----
==== ====
`@javax.persistence.Id` marks the property which defines the entity's identifier. `@jakarta.persistence.Id` marks the property which defines the entity's identifier.
`@javax.persistence.GeneratedValue` and `@org.hibernate.annotations.GenericGenerator` work in tandem `@jakarta.persistence.GeneratedValue` and `@org.hibernate.annotations.GenericGenerator` work in tandem
to indicate that Hibernate should use Hibernate's `increment` generation strategy for this entity's identifier values. to indicate that Hibernate should use Hibernate's `increment` generation strategy for this entity's identifier values.

View File

@ -47,7 +47,7 @@ public void testBasicUsage() {
==== ====
We see that an `org.hibernate.envers.AuditReader` is obtained from the `org.hibernate.envers.AuditReaderFactory` We see that an `org.hibernate.envers.AuditReader` is obtained from the `org.hibernate.envers.AuditReaderFactory`
which wraps the `javax.persistence.EntityManager`. which wraps the `jakarta.persistence.EntityManager`.
Next, the `find` method retrieves specific revisions of the entity. The first call says to find revision number Next, the `find` method retrieves specific revisions of the entity. The first call says to find revision number
1 of Event with id 2. The second call says to find revision number 2 of Event with id 2. 1 of Event with id 2. The second call says to find revision number 2 of Event with id 2.

View File

@ -35,12 +35,15 @@ is required to locate all JPA configuration files by classpath lookup of the `ME
==== ====
`persistence.xml` files should provide a unique name for each "persistence unit". Applications use this name to `persistence.xml` files should provide a unique name for each "persistence unit". Applications use this name to
reference the configuration when obtaining an `javax.persistence.EntityManagerFactory` reference. reference the configuration when obtaining an `jakarta.persistence.EntityManagerFactory` reference.
The settings defined in the `<properties/>` element are discussed in <<hibernate-gsg-tutorial-basic-config>>. The settings defined in the `<properties/>` element are discussed in <<hibernate-gsg-tutorial-basic-config>>.
Here the `javax.persistence`-prefixed varieties are used when possible. Notice that the remaining Here the `jakarta.persistence`-prefixed varieties are used when possible. Notice that the remaining
Hibernate-specific configuration setting names are now prefixed with `hibernate.`. Hibernate-specific configuration setting names are now prefixed with `hibernate.`.
NOTE:: Configuration properties prefixed with the legacy Java EE "namespace" (`javax.persistence.*`) are also still
supported, although the Jakarta EE version (`jakarta.persistence.*`) should be preferred
Additionally, the `<class/>` element functions the same as we saw in <<hibernate-gsg-tutorial-annotations-config>>. Additionally, the `<class/>` element functions the same as we saw in <<hibernate-gsg-tutorial-annotations-config>>.
@ -56,7 +59,7 @@ The entity is exactly the same as in <<hibernate-gsg-tutorial-annotations-entity
The previous tutorials used the Hibernate native APIs. This tutorial uses the JPA APIs. The previous tutorials used the Hibernate native APIs. This tutorial uses the JPA APIs.
[[hibernate-gsg-tutorial-jpa-test-setUp]] [[hibernate-gsg-tutorial-jpa-test-setUp]]
.Obtaining the javax.persistence.EntityManagerFactory .Obtaining the jakarta.persistence.EntityManagerFactory
==== ====
[source, JAVA] [source, JAVA]
---- ----
@ -83,7 +86,7 @@ entityManager.close();
---- ----
==== ====
The code is similar to <<hibernate-gsg-tutorial-basic-test-saving>>. The `javax.persistence.EntityManager` interface The code is similar to <<hibernate-gsg-tutorial-basic-test-saving>>. The `jakarta.persistence.EntityManager` interface
is used instead of the `org.hibernate.Session` interface. JPA calls this operation "persist" instead of "save". is used instead of the `org.hibernate.Session` interface. JPA calls this operation "persist" instead of "save".

View File

@ -24,13 +24,13 @@
package org.hibernate.tutorial.annotations; package org.hibernate.tutorial.annotations;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
import javax.persistence.Temporal; import jakarta.persistence.Temporal;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;

View File

@ -25,9 +25,9 @@ package org.hibernate.tutorial.em;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.Persistence; import jakarta.persistence.Persistence;
import junit.framework.TestCase; import junit.framework.TestCase;

View File

@ -24,13 +24,13 @@
package org.hibernate.tutorial.em; package org.hibernate.tutorial.em;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
import javax.persistence.Temporal; import jakarta.persistence.Temporal;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;

View File

@ -17,10 +17,10 @@
<class>org.hibernate.tutorial.em.Event</class> <class>org.hibernate.tutorial.em.Event</class>
<properties> <properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> <property name="jakarta.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" /> <property name="jakarta.persistence.jdbc.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
<property name="javax.persistence.jdbc.user" value="sa" /> <property name="jakarta.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" /> <property name="jakarta.persistence.jdbc.password" value="" />
<property name="hibernate.show_sql" value="true" /> <property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.hbm2ddl.auto" value="create" />

View File

@ -25,9 +25,9 @@ package org.hibernate.tutorial.envers;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.Persistence; import jakarta.persistence.Persistence;
import junit.framework.TestCase; import junit.framework.TestCase;

View File

@ -24,13 +24,13 @@
package org.hibernate.tutorial.envers; package org.hibernate.tutorial.envers;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
import javax.persistence.Temporal; import jakarta.persistence.Temporal;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;

View File

@ -17,10 +17,10 @@
<class>org.hibernate.tutorial.envers.Event</class> <class>org.hibernate.tutorial.envers.Event</class>
<properties> <properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> <property name="jakarta.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" /> <property name="jakarta.persistence.jdbc.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
<property name="javax.persistence.jdbc.user" value="sa" /> <property name="jakarta.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" /> <property name="jakarta.persistence.jdbc.password" value="" />
<property name="hibernate.show_sql" value="true" /> <property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.hbm2ddl.auto" value="create" />

View File

@ -22,7 +22,7 @@ package org.hibernate.osgitest;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.hibernate.osgitest.entity.DataPoint; import org.hibernate.osgitest.entity.DataPoint;

View File

@ -20,9 +20,9 @@
*/ */
package org.hibernate.osgitest.entity; package org.hibernate.osgitest.entity;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
/** /**
* @author Brett Meyer * @author Brett Meyer

View File

@ -22,7 +22,7 @@ package org.hibernate.osgitest;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.hibernate.osgitest.entity.DataPoint; import org.hibernate.osgitest.entity.DataPoint;

View File

@ -20,9 +20,9 @@
*/ */
package org.hibernate.osgitest; package org.hibernate.osgitest;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.spi.PersistenceProvider; import jakarta.persistence.spi.PersistenceProvider;
import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;

View File

@ -20,9 +20,9 @@
*/ */
package org.hibernate.osgitest.entity; package org.hibernate.osgitest.entity;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
/** /**
* @author Brett Meyer * @author Brett Meyer

View File

@ -22,9 +22,9 @@ package org.hibernate.osgitest.entity;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;

View File

@ -10,9 +10,9 @@ the _Native Bootstrapping_ guide as well.
== JPA-compliant bootstrapping == JPA-compliant bootstrapping
In JPA we are ultimately interested in bootstrapping an `javax.persistence.EntityManagerFactory` instance. The In JPA we are ultimately interested in bootstrapping an `jakarta.persistence.EntityManagerFactory` instance. The
JPA specification defines 2 primary standardized bootstrap approaches depending on how the application intends to JPA specification defines 2 primary standardized bootstrap approaches depending on how the application intends to
access the `javax.persistence.EntityManager` instances from an `EntityManagerFactory`. It uses the terms "EE" and access the `jakarta.persistence.EntityManager` instances from an `EntityManagerFactory`. It uses the terms "EE" and
"SE" for these 2 approaches, but those terms are very misleading in this context. What the JPA spec calls EE "SE" for these 2 approaches, but those terms are very misleading in this context. What the JPA spec calls EE
bootstrapping is cases where a container (EE, OSGi, etc) will manage and inject the persistence context on behalf bootstrapping is cases where a container (EE, OSGi, etc) will manage and inject the persistence context on behalf
of the application. What it calls SE bootstrapping is everything else. We will use the terms of the application. What it calls SE bootstrapping is everything else. We will use the terms
@ -27,7 +27,7 @@ respectively.
The container will build an `EntityManagerFactory` for each persistent-unit defined in the deployment's The container will build an `EntityManagerFactory` for each persistent-unit defined in the deployment's
`META-INF/persistence.xml` and make that available to the application for injection via the `META-INF/persistence.xml` and make that available to the application for injection via the
`javax.persistence.PersistenceUnit` annotation or via JNDI lookup. `jakarta.persistence.PersistenceUnit` annotation or via JNDI lookup.
[[container-bootstrap-injection-example]] [[container-bootstrap-injection-example]]
.Injecting a EntityManagerFactory .Injecting a EntityManagerFactory
@ -43,7 +43,7 @@ EntityManagerFactory emf;
=== Application-bootstrapping === Application-bootstrapping
Rather than something a container building the `EntityManagerFactory` for the application, the application Rather than something a container building the `EntityManagerFactory` for the application, the application
can build the `EntityManagerFactory` using the `javax.persistence.Persistence` bootstrap class. The application can build the `EntityManagerFactory` using the `jakarta.persistence.Persistence` bootstrap class. The application
creates an entity manager factory by calling the createEntityManagerFactory method: creates an entity manager factory by calling the createEntityManagerFactory method:
[[application-bootstrap-example]] [[application-bootstrap-example]]

View File

@ -126,7 +126,7 @@ package p is created.
managed class by appending "_" to the name of the managed class. managed class by appending "_" to the name of the managed class.
* The metamodel class X_ must be annotated with the * The metamodel class X_ must be annotated with the
`javax.persistence.StaticMetamodel` annotation. `jakarta.persistence.StaticMetamodel` annotation.
* If class X extends another class S, where S is the most derived * If class X extends another class S, where S is the most derived
managed class (i.e., entity or mapped superclass) extended by X, then managed class (i.e., entity or mapped superclass) extended by X, then
@ -160,7 +160,7 @@ a declaration as follows:
+ +
where K is the type of the key of the map in class X where K is the type of the key of the map in class X
Import statements must be included for the needed `javax.persistence.metamodel` types as Import statements must be included for the needed `jakarta.persistence.metamodel` types as
appropriate and all classes X, Y, Z, and K. appropriate and all classes X, Y, Z, and K.
[[chapter-usage]] [[chapter-usage]]

View File

@ -27,7 +27,6 @@ include::chapters/query/criteria/Criteria.adoc[]
include::chapters/query/native/Native.adoc[] include::chapters/query/native/Native.adoc[]
include::chapters/query/spatial/Spatial.adoc[] include::chapters/query/spatial/Spatial.adoc[]
include::chapters/multitenancy/MultiTenancy.adoc[] include::chapters/multitenancy/MultiTenancy.adoc[]
include::chapters/osgi/OSGi.adoc[]
include::chapters/envers/Envers.adoc[] include::chapters/envers/Envers.adoc[]
include::chapters/portability/Portability.adoc[] include::chapters/portability/Portability.adoc[]
include::chapters/statistics/Statistics.adoc[] include::chapters/statistics/Statistics.adoc[]
@ -38,7 +37,6 @@ include::appendices/BestPractices.adoc[]
include::appendices/Legacy_Bootstrap.adoc[] include::appendices/Legacy_Bootstrap.adoc[]
include::appendices/Legacy_DomainModel.adoc[] include::appendices/Legacy_DomainModel.adoc[]
include::appendices/LegacyBasicTypeResolution.adoc[] include::appendices/LegacyBasicTypeResolution.adoc[]
include::appendices/Legacy_Criteria.adoc[]
include::appendices/Legacy_Native_Queries.adoc[] include::appendices/Legacy_Native_Queries.adoc[]
include::Bibliography.adoc[] include::Bibliography.adoc[]

View File

@ -670,7 +670,7 @@ See the <<chapters/caching/Caching.adoc#caching,Caching>> chapter for more info.
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Cascade.html[`@Cascade`] annotation is used to apply the Hibernate specific https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/CascadeType.html[`CascadeType`] strategies (e.g. `CascadeType.LOCK`, `CascadeType.SAVE_UPDATE`, `CascadeType.REPLICATE`) on a given association. The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Cascade.html[`@Cascade`] annotation is used to apply the Hibernate specific https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/CascadeType.html[`CascadeType`] strategies (e.g. `CascadeType.LOCK`, `CascadeType.SAVE_UPDATE`, `CascadeType.REPLICATE`) on a given association.
For JPA cascading, prefer using the {jpaJavadocUrlPrefix}CascadeType.html[`javax.persistence.CascadeType`] instead. For JPA cascading, prefer using the {jpaJavadocUrlPrefix}CascadeType.html[`jakarta.persistence.CascadeType`] instead.
When combining both JPA and Hibernate `CascadeType` strategies, Hibernate will merge both sets of cascades. When combining both JPA and Hibernate `CascadeType` strategies, Hibernate will merge both sets of cascades.

View File

@ -38,24 +38,24 @@ Note that for backward compatibility, if a `CurrentSessionContext` is not config
=== JPA compliance === JPA compliance
`*hibernate.jpa.compliance.transaction*` (e.g. `true` or `false` (default value)):: `*hibernate.jpa.compliance.transaction*` (e.g. `true` or `false` (default value))::
This setting controls if Hibernate `Transaction` should behave as defined by the spec for JPA's `javax.persistence.EntityTransaction` This setting controls if Hibernate `Transaction` should behave as defined by the spec for JPA's `jakarta.persistence.EntityTransaction`
since it extends the JPA one. since it extends the JPA one.
`*hibernate.jpa.compliance.query*` (e.g. `true` or `false` (default value)):: `*hibernate.jpa.compliance.query*` (e.g. `true` or `false` (default value))::
Controls whether Hibernate's handling of `javax.persistence.Query` (JPQL, Criteria and native query) should strictly follow the JPA spec. Controls whether Hibernate's handling of `jakarta.persistence.Query` (JPQL, Criteria and native query) should strictly follow the JPA spec.
+ +
This includes both in terms of parsing or translating a query as well as calls to the `javax.persistence.Query` methods throwing spec This includes both in terms of parsing or translating a query as well as calls to the `jakarta.persistence.Query` methods throwing spec
defined exceptions whereas Hibernate might not. defined exceptions whereas Hibernate might not.
`*hibernate.jpa.compliance.list*` (e.g. `true` or `false` (default value)):: `*hibernate.jpa.compliance.list*` (e.g. `true` or `false` (default value))::
Controls whether Hibernate should recognize what it considers a "bag" (`org.hibernate.collection.internal.PersistentBag`) Controls whether Hibernate should recognize what it considers a "bag" (`org.hibernate.collection.internal.PersistentBag`)
as a List (`org.hibernate.collection.internal.PersistentList`) or as a bag. as a List (`org.hibernate.collection.internal.PersistentList`) or as a bag.
+ +
If enabled, we will recognize it as a List where `javax.persistence.OrderColumn` If enabled, we will recognize it as a List where `jakarta.persistence.OrderColumn`
is just missing (and its defaults will apply). is just missing (and its defaults will apply).
`*hibernate.jpa.compliance.closed*` (e.g. `true` or `false` (default value)):: `*hibernate.jpa.compliance.closed*` (e.g. `true` or `false` (default value))::
JPA defines specific exceptions upon calling specific methods on `javax.persistence.EntityManager` and `javax.persistence.EntityManagerFactory` JPA defines specific exceptions upon calling specific methods on `jakarta.persistence.EntityManager` and `jakarta.persistence.EntityManagerFactory`
objects which have been closed previously. objects which have been closed previously.
+ +
This setting controls whether the JPA spec-defined behavior or the Hibernate behavior will be used. This setting controls whether the JPA spec-defined behavior or the Hibernate behavior will be used.
@ -63,7 +63,7 @@ This setting controls whether the JPA spec-defined behavior or the Hibernate beh
If enabled, Hibernate will operate in the JPA specified way, throwing exceptions when the spec says it should. If enabled, Hibernate will operate in the JPA specified way, throwing exceptions when the spec says it should.
`*hibernate.jpa.compliance.proxy*` (e.g. `true` or `false` (default value)):: `*hibernate.jpa.compliance.proxy*` (e.g. `true` or `false` (default value))::
The JPA spec says that a `javax.persistence.EntityNotFoundException` should be thrown when accessing an entity proxy The JPA spec says that a `jakarta.persistence.EntityNotFoundException` should be thrown when accessing an entity proxy
which does not have an associated table row in the database. which does not have an associated table row in the database.
+ +
Traditionally, Hibernate does not initialize an entity proxy when accessing its identifier since we already know the identifier value, Traditionally, Hibernate does not initialize an entity proxy when accessing its identifier since we already know the identifier value,
@ -82,16 +82,16 @@ with the same name will cause a `java.lang.IllegalArgumentException` to be throw
[[configurations-database-connection]] [[configurations-database-connection]]
=== Database connection properties === Database connection properties
`*hibernate.connection.driver_class*` or `*javax.persistence.jdbc.driver*` (e.g. `org.postgresql.Driver`):: `*hibernate.connection.driver_class*` or `*jakarta.persistence.jdbc.driver*` (e.g. `org.postgresql.Driver`)::
Names the JDBC `Driver` class name. Names the JDBC `Driver` class name.
`*hibernate.connection.url*` or `*javax.persistence.jdbc.url*` (e.g. `jdbc:postgresql:hibernate_orm_test`):: `*hibernate.connection.url*` or `*jakarta.persistence.jdbc.url*` (e.g. `jdbc:postgresql:hibernate_orm_test`)::
Names the JDBC connection URL. Names the JDBC connection URL.
`*hibernate.connection.username*` or `*javax.persistence.jdbc.user*`:: `*hibernate.connection.username*` or `*jakarta.persistence.jdbc.user*`::
Names the JDBC connection user name. Names the JDBC connection user name.
`*hibernate.connection.password*` or `*javax.persistence.jdbc.password*`:: `*hibernate.connection.password*` or `*jakarta.persistence.jdbc.password*`::
Names the JDBC connection password. Names the JDBC connection password.
`*hibernate.connection.isolation*` (e.g. `REPEATABLE_READ` or `Connection.TRANSACTION_REPEATABLE_READ`):: `*hibernate.connection.isolation*` (e.g. `REPEATABLE_READ` or `Connection.TRANSACTION_REPEATABLE_READ`)::
@ -289,8 +289,8 @@ meaning that an Exception is thrown when detecting such a conflict.
Should all database identifiers be quoted. Should all database identifiers be quoted.
`*hibernate.globally_quoted_identifiers_skip_column_definitions*` (e.g. `true` or `false` (default value)):: `*hibernate.globally_quoted_identifiers_skip_column_definitions*` (e.g. `true` or `false` (default value))::
Assuming `hibernate.globally_quoted_identifiers` is `true`, this allows the global quoting to skip column-definitions as defined by `javax.persistence.Column`, Assuming `hibernate.globally_quoted_identifiers` is `true`, this allows the global quoting to skip column-definitions as defined by `jakarta.persistence.Column`,
`javax.persistence.JoinColumn`, etc., and while it avoids column-definitions being quoted due to global quoting, they can still be explicitly quoted in the annotation/xml mappings. `jakarta.persistence.JoinColumn`, etc., and while it avoids column-definitions being quoted due to global quoting, they can still be explicitly quoted in the annotation/xml mappings.
`*hibernate.auto_quote_keyword*` (e.g. `true` or `false` (default value)):: `*hibernate.auto_quote_keyword*` (e.g. `true` or `false` (default value))::
Specifies whether to automatically quote any names that are deemed keywords. Specifies whether to automatically quote any names that are deemed keywords.
@ -393,7 +393,7 @@ Unless specified, the JDBC Driver uses the default JVM time zone. If a different
This setting applies to Oracle Dialect only, and it specifies whether `byte[]` or `Byte[]` arrays should be mapped to the deprecated `LONG RAW` (when this configuration property value is `true`) or to a `BLOB` column type (when this configuration property value is `false`). This setting applies to Oracle Dialect only, and it specifies whether `byte[]` or `Byte[]` arrays should be mapped to the deprecated `LONG RAW` (when this configuration property value is `true`) or to a `BLOB` column type (when this configuration property value is `false`).
==== Bean Validation options ==== Bean Validation options
`*javax.persistence.validation.factory*` (e.g. `javax.validation.ValidationFactory` implementation):: `*jakarta.persistence.validation.factory*` (e.g. `jakarta.validation.ValidationFactory` implementation)::
Specify the `javax.validation.ValidationFactory` implementation to use for Bean Validation. Specify the `javax.validation.ValidationFactory` implementation to use for Bean Validation.
`*hibernate.check_nullability*` (e.g. `true` or `false`):: `*hibernate.check_nullability*` (e.g. `true` or `false`)::
@ -499,7 +499,7 @@ Can reference a
`*hibernate.query.validate_parameters*` (e.g. `true` (default value) or `false`):: `*hibernate.query.validate_parameters*` (e.g. `true` (default value) or `false`)::
This configuration property can be used to disable parameters validation performed by `org.hibernate.query.Query#setParameter` when the Session is bootstrapped via JPA This configuration property can be used to disable parameters validation performed by `org.hibernate.query.Query#setParameter` when the Session is bootstrapped via JPA
`javax.persistence.EntityManagerFactory`. `jakarta.persistence.EntityManagerFactory`.
`*hibernate.criteria.value_handling_mode*` (e.g. `BIND` (default value) or `INLINE`):: `*hibernate.criteria.value_handling_mode*` (e.g. `BIND` (default value) or `INLINE`)::
By default, Criteria queries uses bind parameters for any value passed through the JPA Criteria API. By default, Criteria queries uses bind parameters for any value passed through the JPA Criteria API.
@ -535,7 +535,7 @@ This way, an IN clause with 5, 6, or 7 bind parameters will use the 8 IN clause,
therefore reusing its execution plan. therefore reusing its execution plan.
`*hibernate.query.omit_join_of_superclass_tables*` (e.g. `false` or `true` (default value)):: `*hibernate.query.omit_join_of_superclass_tables*` (e.g. `false` or `true` (default value))::
When you use `javax.persistence.InheritanceType#JOINED` strategy for inheritance mapping and query When you use `jakarta.persistence.InheritanceType#JOINED` strategy for inheritance mapping and query
a value from an entity, all superclass tables are joined in the query regardless you need them. a value from an entity, all superclass tables are joined in the query regardless you need them.
+ +
With this setting set to true only superclass tables which are really needed are joined. With this setting set to true only superclass tables which are really needed are joined.
@ -680,7 +680,7 @@ Either a shortcut name (e.g. `jcache`, `ehcache`) or the fully-qualified name of
`*hibernate.cache.default_cache_concurrency_strategy*`:: `*hibernate.cache.default_cache_concurrency_strategy*`::
Setting used to give the name of the default https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/CacheConcurrencyStrategy.html[`CacheConcurrencyStrategy`] to use Setting used to give the name of the default https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/CacheConcurrencyStrategy.html[`CacheConcurrencyStrategy`] to use
when `@javax.persistence.Cacheable`, `@org.hibernate.annotations.Cache` or `@org.hibernate.annotations.Cache` is used to override the global setting. when `@jakarta.persistence.Cacheable`, `@org.hibernate.annotations.Cache` or `@org.hibernate.annotations.Cache` is used to override the global setting.
`*hibernate.cache.use_minimal_puts*` (e.g. `true` (default value) or `false`):: `*hibernate.cache.use_minimal_puts*` (e.g. `true` (default value) or `false`)::
Optimizes second-level cache operation to minimize writes, at the cost of more frequent reads. This is most useful for clustered caches and is enabled by default for clustered cache implementations. Optimizes second-level cache operation to minimize writes, at the cost of more frequent reads. This is most useful for clustered caches and is enabled by default for clustered cache implementations.
@ -813,7 +813,7 @@ Valid options are defined by the `externalHbm2ddlName` value of the https://docs
`validate`::: Validate the database schema. `validate`::: Validate the database schema.
`update`::: Update the database schema. `update`::: Update the database schema.
`*javax.persistence.schema-generation.database.action*` (e.g. `none` (default value), `create-only`, `drop`, `create`, `create-drop`, `validate`, and `update`):: `*jakarta.persistence.schema-generation.database.action*` (e.g. `none` (default value), `create-only`, `drop`, `create`, `create-drop`, `validate`, and `update`)::
Setting to perform `SchemaManagementTool` actions automatically as part of the `SessionFactory` lifecycle. Setting to perform `SchemaManagementTool` actions automatically as part of the `SessionFactory` lifecycle.
Valid options are defined by the `externalJpaName` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/Action.html[`Action`] enum: Valid options are defined by the `externalJpaName` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/Action.html[`Action`] enum:
+ +
@ -822,7 +822,7 @@ Valid options are defined by the `externalJpaName` value of the https://docs.jbo
`drop`::: Database dropping will be generated. `drop`::: Database dropping will be generated.
`drop-and-create`::: Database dropping will be generated followed by database creation. `drop-and-create`::: Database dropping will be generated followed by database creation.
`*javax.persistence.schema-generation.scripts.action*` (e.g. `none` (default value), `create-only`, `drop`, `create`, `create-drop`, `validate`, and `update`):: `*jakarta.persistence.schema-generation.scripts.action*` (e.g. `none` (default value), `create-only`, `drop`, `create`, `create-drop`, `validate`, and `update`)::
Setting to perform `SchemaManagementTool` actions writing the commands into a DDL script file. Setting to perform `SchemaManagementTool` actions writing the commands into a DDL script file.
Valid options are defined by the `externalJpaName` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/Action.html[`Action`] enum: Valid options are defined by the `externalJpaName` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/Action.html[`Action`] enum:
+ +
@ -831,77 +831,77 @@ Valid options are defined by the `externalJpaName` value of the https://docs.jbo
`drop`::: Database dropping will be generated. `drop`::: Database dropping will be generated.
`drop-and-create`::: Database dropping will be generated followed by database creation. `drop-and-create`::: Database dropping will be generated followed by database creation.
`*javax.persistence.schema-generation-connection*`:: `*jakarta.persistence.schema-generation-connection*`::
Allows passing a specific `java.sql.Connection` instance to be used by `SchemaManagementTool`. Allows passing a specific `java.sql.Connection` instance to be used by `SchemaManagementTool`.
`*javax.persistence.database-product-name*`:: `*jakarta.persistence.database-product-name*`::
Specifies the name of the database provider in cases where a Connection to the underlying database is not available (aka, mainly in generating scripts). Specifies the name of the database provider in cases where a Connection to the underlying database is not available (aka, mainly in generating scripts).
In such cases, a value for this setting _must_ be specified. In such cases, a value for this setting _must_ be specified.
+ +
The value of this setting is expected to match the value returned by `java.sql.DatabaseMetaData#getDatabaseProductName()` for the target database. The value of this setting is expected to match the value returned by `java.sql.DatabaseMetaData#getDatabaseProductName()` for the target database.
+ +
Additionally, specifying `javax.persistence.database-major-version` and/or `javax.persistence.database-minor-version` may be required to understand exactly how to generate the required schema commands. Additionally, specifying `jakarta.persistence.database-major-version` and/or `jakarta.persistence.database-minor-version` may be required to understand exactly how to generate the required schema commands.
`*javax.persistence.database-major-version*`:: `*jakarta.persistence.database-major-version*`::
Specifies the major version of the underlying database, as would be returned by `java.sql.DatabaseMetaData#getDatabaseMajorVersion` for the target database. Specifies the major version of the underlying database, as would be returned by `java.sql.DatabaseMetaData#getDatabaseMajorVersion` for the target database.
+ +
This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where `javax.persistence.database-product-name` does not provide enough distinction. This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where `jakarta.persistence.database-product-name` does not provide enough distinction.
`*javax.persistence.database-minor-version*`:: `*jakarta.persistence.database-minor-version*`::
Specifies the minor version of the underlying database, as would be returned by `java.sql.DatabaseMetaData#getDatabaseMinorVersion` for the target database. Specifies the minor version of the underlying database, as would be returned by `java.sql.DatabaseMetaData#getDatabaseMinorVersion` for the target database.
+ +
This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where `javax.persistence.database-product-name` and `javax.persistence.database-major-version` does not provide enough distinction. This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where `jakarta.persistence.database-product-name` and `jakarta.persistence.database-major-version` does not provide enough distinction.
`*javax.persistence.schema-generation.create-source*`:: `*jakarta.persistence.schema-generation.create-source*`::
Specifies whether schema generation commands for schema creation are to be determined based on object/relational mapping metadata, DDL scripts, or a combination of the two. Specifies whether schema generation commands for schema creation are to be determined based on object/relational mapping metadata, DDL scripts, or a combination of the two.
See https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/SourceType.html[`SourceType`] for valid set of values. See https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/SourceType.html[`SourceType`] for valid set of values.
+ +
If no value is specified, a default is assumed as follows: If no value is specified, a default is assumed as follows:
+ +
* if source scripts are specified (per `javax.persistence.schema-generation.create-script-source`), then `script` is assumed * if source scripts are specified (per `jakarta.persistence.schema-generation.create-script-source`), then `script` is assumed
* otherwise, `metadata` is assumed * otherwise, `metadata` is assumed
`*javax.persistence.schema-generation.drop-source*`:: `*jakarta.persistence.schema-generation.drop-source*`::
Specifies whether schema generation commands for schema dropping are to be determined based on object/relational mapping metadata, DDL scripts, or a combination of the two. Specifies whether schema generation commands for schema dropping are to be determined based on object/relational mapping metadata, DDL scripts, or a combination of the two.
See https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/SourceType.html[`SourceType`] for valid set of values. See https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/SourceType.html[`SourceType`] for valid set of values.
+ +
If no value is specified, a default is assumed as follows: If no value is specified, a default is assumed as follows:
+ +
* if source scripts are specified (per `javax.persistence.schema-generation.drop-script-source`), then the `script` option is assumed * if source scripts are specified (per `jakarta.persistence.schema-generation.drop-script-source`), then the `script` option is assumed
* otherwise, `metadata` is assumed * otherwise, `metadata` is assumed
`*javax.persistence.schema-generation.create-script-source*`:: `*jakarta.persistence.schema-generation.create-script-source*`::
Specifies the `create` script file as either a `java.io.Reader` configured for reading of the DDL script file or a string designating a file `java.net.URL` for the DDL script. Specifies the `create` script file as either a `java.io.Reader` configured for reading of the DDL script file or a string designating a file `java.net.URL` for the DDL script.
+ +
Hibernate historically also accepted `hibernate.hbm2ddl.import_files` for a similar purpose, but `javax.persistence.schema-generation.create-script-source` should be preferred over `hibernate.hbm2ddl.import_files`. Hibernate historically also accepted `hibernate.hbm2ddl.import_files` for a similar purpose, but `jakarta.persistence.schema-generation.create-script-source` should be preferred over `hibernate.hbm2ddl.import_files`.
`*javax.persistence.schema-generation.drop-script-source*`:: `*jakarta.persistence.schema-generation.drop-script-source*`::
Specifies the `drop` script file as either a `java.io.Reader` configured for reading of the DDL script file or a string designating a file `java.net.URL` for the DDL script. Specifies the `drop` script file as either a `java.io.Reader` configured for reading of the DDL script file or a string designating a file `java.net.URL` for the DDL script.
`*javax.persistence.schema-generation.scripts.create-target*`:: `*jakarta.persistence.schema-generation.scripts.create-target*`::
For cases where the `javax.persistence.schema-generation.scripts.action` value indicates that schema creation commands should be written to DDL script file, `javax.persistence.schema-generation.scripts.create-target` specifies either a `java.io.Writer` configured for output of the DDL script or a string specifying the file URL for the DDL script. For cases where the `jakarta.persistence.schema-generation.scripts.action` value indicates that schema creation commands should be written to DDL script file, `jakarta.persistence.schema-generation.scripts.create-target` specifies either a `java.io.Writer` configured for output of the DDL script or a string specifying the file URL for the DDL script.
`*javax.persistence.schema-generation.scripts.drop-target*`:: `*jakarta.persistence.schema-generation.scripts.drop-target*`::
For cases where the `javax.persistence.schema-generation.scripts.action` value indicates that schema dropping commands should be written to DDL script file, `javax.persistence.schema-generation.scripts.drop-target` specifies either a `java.io.Writer` configured for output of the DDL script or a string specifying the file URL for the DDL script. For cases where the `jakarta.persistence.schema-generation.scripts.action` value indicates that schema dropping commands should be written to DDL script file, `jakarta.persistence.schema-generation.scripts.drop-target` specifies either a `java.io.Writer` configured for output of the DDL script or a string specifying the file URL for the DDL script.
`*hibernate.hbm2ddl.schema-generation.script.append*` (e.g. `true` (default value) or `false`):: `*hibernate.hbm2ddl.schema-generation.script.append*` (e.g. `true` (default value) or `false`)::
For cases where the `javax.persistence.schema-generation.scripts.action` value indicates that schema commands should be written to DDL script file, `hibernate.hbm2ddl.schema-generation.script.append` specifies if schema commands should be appended to the end of the file rather than written at the beginning of the file. For cases where the `jakarta.persistence.schema-generation.scripts.action` value indicates that schema commands should be written to DDL script file, `hibernate.hbm2ddl.schema-generation.script.append` specifies if schema commands should be appended to the end of the file rather than written at the beginning of the file.
Values are `true` for appending schema commands to the end of the file, `false` for writing achema commands at the beginning of the file. Values are `true` for appending schema commands to the end of the file, `false` for writing achema commands at the beginning of the file.
`*javax.persistence.hibernate.hbm2ddl.import_files*` (e.g. `import.sql` (default value)):: `*jakarta.persistence.hibernate.hbm2ddl.import_files*` (e.g. `import.sql` (default value))::
Comma-separated names of the optional files containing SQL DML statements executed during the `SessionFactory` creation. Comma-separated names of the optional files containing SQL DML statements executed during the `SessionFactory` creation.
File order matters, the statements of a given file are executed before the statements of the following one. File order matters, the statements of a given file are executed before the statements of the following one.
+ +
These statements are only executed if the schema is created, meaning that `hibernate.hbm2ddl.auto` is set to `create`, `create-drop`, or `update`. These statements are only executed if the schema is created, meaning that `hibernate.hbm2ddl.auto` is set to `create`, `create-drop`, or `update`.
`javax.persistence.schema-generation.create-script-source` / `javax.persistence.schema-generation.drop-script-source` should be preferred. `jakarta.persistence.schema-generation.create-script-source` / `jakarta.persistence.schema-generation.drop-script-source` should be preferred.
`*javax.persistence.sql-load-script-source*`:: `*jakarta.persistence.sql-load-script-source*`::
JPA variant of `hibernate.hbm2ddl.import_files`. Specifies a `java.io.Reader` configured for reading of the SQL load script or a string designating the file `java.net.URL` for the SQL load script. JPA variant of `hibernate.hbm2ddl.import_files`. Specifies a `java.io.Reader` configured for reading of the SQL load script or a string designating the file `java.net.URL` for the SQL load script.
A "SQL load script" is a script that performs some database initialization (INSERT, etc). A "SQL load script" is a script that performs some database initialization (INSERT, etc).
`*hibernate.hbm2ddl.import_files_sql_extractor*`:: `*hibernate.hbm2ddl.import_files_sql_extractor*`::
Reference to the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractor.html[`ImportSqlCommandExtractor`] implementation class to use for parsing source/import files as defined by `javax.persistence.schema-generation.create-script-source`, Reference to the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/hbm2ddl/ImportSqlCommandExtractor.html[`ImportSqlCommandExtractor`] implementation class to use for parsing source/import files as defined by `jakarta.persistence.schema-generation.create-script-source`,
`javax.persistence.schema-generation.drop-script-source` or `hibernate.hbm2ddl.import_files`. `jakarta.persistence.schema-generation.drop-script-source` or `hibernate.hbm2ddl.import_files`.
+ +
Reference may refer to an instance, a Class implementing `ImportSqlCommandExtractor` or the fully-qualified name of the `ImportSqlCommandExtractor` implementation. Reference may refer to an instance, a Class implementing `ImportSqlCommandExtractor` or the fully-qualified name of the `ImportSqlCommandExtractor` implementation.
If the fully-qualified name is given, the implementation must provide a no-arg constructor. If the fully-qualified name is given, the implementation must provide a no-arg constructor.
@ -911,7 +911,7 @@ The default value is https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/ja
`*hibernate.hbm2ddl.create_namespaces*` (e.g. `true` or `false` (default value)):: `*hibernate.hbm2ddl.create_namespaces*` (e.g. `true` or `false` (default value))::
Specifies whether to automatically create the database schema/catalog also. Specifies whether to automatically create the database schema/catalog also.
`*javax.persistence.create-database-schemas*` (e.g. `true` or `false` (default value)):: `*jakarta.persistence.create-database-schemas*` (e.g. `true` or `false` (default value))::
The JPA variant of `hibernate.hbm2ddl.create_namespaces`. Specifies whether the persistence provider is to create the database schema(s) in addition to creating database objects (tables, sequences, constraints, etc). The JPA variant of `hibernate.hbm2ddl.create_namespaces`. Specifies whether the persistence provider is to create the database schema(s) in addition to creating database objects (tables, sequences, constraints, etc).
The value of this boolean property should be set to `true` if the persistence provider is to create schemas in the database or to generate DDL that contains "CREATE SCHEMA" commands. The value of this boolean property should be set to `true` if the persistence provider is to create schemas in the database or to generate DDL that contains "CREATE SCHEMA" commands.
+ +
@ -925,8 +925,8 @@ Used to specify the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/jav
Setting to choose the strategy used to access the JDBC Metadata. Setting to choose the strategy used to access the JDBC Metadata.
Valid options are defined by the `strategy` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.html[`JdbcMetadaAccessStrategy`] enum: Valid options are defined by the `strategy` value of the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.html[`JdbcMetadaAccessStrategy`] enum:
+ +
`grouped`::: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaMigrator.html[`SchemaMigrator`] and https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaValidator.html[`SchemaValidator`] execute a single `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call to retrieve all the database table in order to determine if all the ``javax.persistence.Entity``s have a corresponding mapped database tables. This strategy may require `hibernate.default_schema` and/or `hibernate.default_catalog` to be provided. `grouped`::: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaMigrator.html[`SchemaMigrator`] and https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaValidator.html[`SchemaValidator`] execute a single `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call to retrieve all the database table in order to determine if all the ``jakarta.persistence.Entity``s have a corresponding mapped database tables. This strategy may require `hibernate.default_schema` and/or `hibernate.default_catalog` to be provided.
`individually`::: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaMigrator.html[`SchemaMigrator`] and https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaValidator.html[`SchemaValidator`] execute one `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call for each `javax.persistence.Entity` in order to determine if a corresponding database table exists. `individually`::: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaMigrator.html[`SchemaMigrator`] and https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/tool/schema/spi/SchemaValidator.html[`SchemaValidator`] execute one `java.sql.DatabaseMetaData#getTables(String, String, String, String[])` call for each `jakarta.persistence.Entity` in order to determine if a corresponding database table exists.
`*hibernate.hbm2ddl.delimiter*` (e.g. `;`):: `*hibernate.hbm2ddl.delimiter*` (e.g. `;`)::
Identifies the delimiter to use to separate schema management statements in script outputs. Identifies the delimiter to use to separate schema management statements in script outputs.
@ -942,7 +942,7 @@ If enabled, allows schema update and validation to support synonyms. Due to the
Identifies a comma-separated list of values to specify extra table types, other than the default `TABLE` value, to recognize as defining a physical table by schema update, creation and validation. Identifies a comma-separated list of values to specify extra table types, other than the default `TABLE` value, to recognize as defining a physical table by schema update, creation and validation.
`*hibernate.hbm2ddl.default_constraint_mode*` (`CONSTRAINT` (default value) or `NO_CONSTRAINT`):: `*hibernate.hbm2ddl.default_constraint_mode*` (`CONSTRAINT` (default value) or `NO_CONSTRAINT`)::
Default `javax.persistence.ConstraintMode` for foreign key mapping if `PROVIDER_DEFAULT` strategy used. Default `jakarta.persistence.ConstraintMode` for foreign key mapping if `PROVIDER_DEFAULT` strategy used.
`*hibernate.schema_update.unique_constraint_strategy*` (e.g. `DROP_RECREATE_QUIETLY`, `RECREATE_QUIETLY`, `SKIP`):: `*hibernate.schema_update.unique_constraint_strategy*` (e.g. `DROP_RECREATE_QUIETLY`, `RECREATE_QUIETLY`, `SKIP`)::
Unique columns and unique keys both use unique constraints in most dialects. Unique columns and unique keys both use unique constraints in most dialects.
@ -1153,7 +1153,7 @@ Defines delayed access to CDI `BeanManager`. Starting in 5.1 the preferred means
Identifies an explicit `org.hibernate.resource.beans.container.spi.BeanContainer` to be used. Identifies an explicit `org.hibernate.resource.beans.container.spi.BeanContainer` to be used.
+ +
Note that, for CDI-based containers, setting this is not necessary. Note that, for CDI-based containers, setting this is not necessary.
Simply pass the `BeanManager` to use via `javax.persistence.bean.manager` and optionally specify `hibernate.delay_cdi_access`. Simply pass the `BeanManager` to use via `jakarta.persistence.bean.manager` and optionally specify `hibernate.delay_cdi_access`.
+ +
This setting is more meant to integrate non-CDI bean containers such as Spring. This setting is more meant to integrate non-CDI bean containers such as Spring.
@ -1169,7 +1169,7 @@ false::: does not allow
Setting which indicates whether or not the new JOINs over collection tables should be rewritten to subqueries. Setting which indicates whether or not the new JOINs over collection tables should be rewritten to subqueries.
`*hibernate.allow_refresh_detached_entity*` (e.g. `true` (default value when using Hibernate native bootstrapping) or `false` (default value when using JPA bootstrapping)):: `*hibernate.allow_refresh_detached_entity*` (e.g. `true` (default value when using Hibernate native bootstrapping) or `false` (default value when using JPA bootstrapping))::
Setting that allows to call `javax.persistence.EntityManager#refresh(entity)` or `Session#refresh(entity)` on a detached instance even when the `org.hibernate.Session` is obtained from a JPA `javax.persistence.EntityManager`. Setting that allows to call `jakarta.persistence.EntityManager#refresh(entity)` or `Session#refresh(entity)` on a detached instance even when the `org.hibernate.Session` is obtained from a JPA `jakarta.persistence.EntityManager`.
`*hibernate.use_entity_where_clause_for_collections*` (e.g., `true` (default) or `false`):: `*hibernate.use_entity_where_clause_for_collections*` (e.g., `true` (default) or `false`)::
Setting controls whether an entity's "where" clause, mapped using `@Where(clause = "...")` or `<entity ... where="...">` is taken into account when loading one-to-many or many-to-many collections of that type of entity. Setting controls whether an entity's "where" clause, mapped using `@Where(clause = "...")` or `<entity ... where="...">` is taken into account when loading one-to-many or many-to-many collections of that type of entity.

View File

@ -182,15 +182,15 @@ The standardized approach has some limitations in certain environments, but asid
[[bootstrap-jpa-compliant]] [[bootstrap-jpa-compliant]]
==== JPA-compliant bootstrapping ==== JPA-compliant bootstrapping
In JPA, we are ultimately interested in bootstrapping a `javax.persistence.EntityManagerFactory` instance. In JPA, we are ultimately interested in bootstrapping a `jakarta.persistence.EntityManagerFactory` instance.
The JPA specification defines two primary standardized bootstrap approaches depending on how the application intends to access the `javax.persistence.EntityManager` instances from an `EntityManagerFactory`. The JPA specification defines two primary standardized bootstrap approaches depending on how the application intends to access the `jakarta.persistence.EntityManager` instances from an `EntityManagerFactory`.
It uses the terms _EE_ and _SE_ for these two approaches, but those terms are very misleading in this context. It uses the terms _EE_ and _SE_ for these two approaches, but those terms are very misleading in this context.
What the JPA spec calls EE bootstrapping implies the existence of a container (EE, OSGi, etc), who'll manage and inject the persistence context on behalf of the application. What the JPA spec calls EE bootstrapping implies the existence of a container (EE, OSGi, etc), who'll manage and inject the persistence context on behalf of the application.
What it calls SE bootstrapping is everything else. We will use the terms container-bootstrapping and application-bootstrapping in this guide. What it calls SE bootstrapping is everything else. We will use the terms container-bootstrapping and application-bootstrapping in this guide.
For compliant container-bootstrapping, the container will build an `EntityManagerFactory` for each persistent-unit defined in the `META-INF/persistence.xml` configuration file For compliant container-bootstrapping, the container will build an `EntityManagerFactory` for each persistent-unit defined in the `META-INF/persistence.xml` configuration file
and make that available to the application for injection via the `javax.persistence.PersistenceUnit` annotation or via JNDI lookup. and make that available to the application for injection via the `jakarta.persistence.PersistenceUnit` annotation or via JNDI lookup.
[[bootstrap-jpa-compliant-PersistenceUnit-example]] [[bootstrap-jpa-compliant-PersistenceUnit-example]]
.Injecting the default `EntityManagerFactory` .Injecting the default `EntityManagerFactory`
@ -224,7 +224,7 @@ include::{extrasdir}/persistence.xml[]
---- ----
==== ====
For compliant application-bootstrapping, rather than the container building the `EntityManagerFactory` for the application, the application builds the `EntityManagerFactory` itself using the `javax.persistence.Persistence` bootstrap class. For compliant application-bootstrapping, rather than the container building the `EntityManagerFactory` for the application, the application builds the `EntityManagerFactory` itself using the `jakarta.persistence.Persistence` bootstrap class.
The application creates an `EntityManagerFactory` by calling the `createEntityManagerFactory` method: The application creates an `EntityManagerFactory` by calling the `createEntityManagerFactory` method:
[[bootstrap-jpa-compliant-EntityManagerFactory-example]] [[bootstrap-jpa-compliant-EntityManagerFactory-example]]
@ -240,7 +240,7 @@ include::{sourcedir}/BootstrapTest.java[tags=bootstrap-jpa-compliant-EntityManag
==== ====
If you don't want to provide a `persistence.xml` configuration file, JPA allows you to provide all the configuration options in a If you don't want to provide a `persistence.xml` configuration file, JPA allows you to provide all the configuration options in a
{jpaJavadocUrlPrefix}spi/PersistenceUnitInfo.html[`PersistenceUnitInfo`] implementation and call {jpaJavadocUrlPrefix}spi/PersistenceUnitInfo.html[`PersistenceUnitInfo`] implementation and call
https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/jpa/HibernatePersistenceProvider.html#createContainerEntityManagerFactory-javax.persistence.spi.PersistenceUnitInfo-java.util.Map-[`HibernatePersistenceProvider.html#createContainerEntityManagerFactory`]. https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/jpa/HibernatePersistenceProvider.html#createContainerEntityManagerFactory-jakarta.persistence.spi.PersistenceUnitInfo-java.util.Map-[`HibernatePersistenceProvider.html#createContainerEntityManagerFactory`].
==== ====
To inject the default Persistence Context, you can use the {jpaJavadocUrlPrefix}PersistenceContext.html[`@PersistenceContext`] annotation. To inject the default Persistence Context, you can use the {jpaJavadocUrlPrefix}PersistenceContext.html[`@PersistenceContext`] annotation.

View File

@ -14,16 +14,16 @@
<mapping-file>file:///etc/opt/app/mappings/orm.xml</mapping-file> <mapping-file>file:///etc/opt/app/mappings/orm.xml</mapping-file>
<properties> <properties>
<property name="javax.persistence.jdbc.driver" <property name="jakarta.persistence.jdbc.driver"
value="org.h2.Driver" /> value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" <property name="jakarta.persistence.jdbc.url"
value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" /> value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
<property name="javax.persistence.jdbc.user" <property name="jakarta.persistence.jdbc.user"
value="sa" /> value="sa" />
<property name="javax.persistence.jdbc.password" <property name="jakarta.persistence.jdbc.password"
value="" /> value="" />
<property name="hibernate.show_sql" <property name="hibernate.show_sql"

View File

@ -14,16 +14,16 @@
<class>org.hibernate.documentation.userguide.Document</class> <class>org.hibernate.documentation.userguide.Document</class>
<properties> <properties>
<property name="javax.persistence.jdbc.driver" <property name="jakarta.persistence.jdbc.driver"
value="org.h2.Driver" /> value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" <property name="jakarta.persistence.jdbc.url"
value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" /> value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE" />
<property name="javax.persistence.jdbc.user" <property name="jakarta.persistence.jdbc.user"
value="sa" /> value="sa" />
<property name="javax.persistence.jdbc.password" <property name="jakarta.persistence.jdbc.password"
value="" /> value="" />
<property name="hibernate.show_sql" <property name="hibernate.show_sql"

View File

@ -85,7 +85,7 @@ The cache mappings can be configured via JPA annotations or XML descriptors or u
By default, entities are not part of the second level cache and we recommend you to stick to this setting. By default, entities are not part of the second level cache and we recommend you to stick to this setting.
However, you can override this by setting the `shared-cache-mode` element in your `persistence.xml` file However, you can override this by setting the `shared-cache-mode` element in your `persistence.xml` file
or by using the `javax.persistence.sharedCache.mode` property in your configuration file. or by using the `jakarta.persistence.sharedCache.mode` property in your configuration file.
The following values are possible: The following values are possible:
`ENABLE_SELECTIVE` (Default and recommended value):: `ENABLE_SELECTIVE` (Default and recommended value)::
@ -460,7 +460,7 @@ include::{sourcedir}/SecondLevelCacheTest.java[tags=caching-management-cache-mod
Because the second level cache is bound to the `EntityManagerFactory` or the `SessionFactory`, Because the second level cache is bound to the `EntityManagerFactory` or the `SessionFactory`,
cache eviction must be done through these two interfaces. cache eviction must be done through these two interfaces.
JPA only supports entity eviction through the {jpaJavadocUrlPrefix}Cache.html[`javax.persistence.Cache`] interface: JPA only supports entity eviction through the {jpaJavadocUrlPrefix}Cache.html[`jakarta.persistence.Cache`] interface:
[[caching-management-evict-jpa-example]] [[caching-management-evict-jpa-example]]
.Evicting entities with JPA .Evicting entities with JPA

View File

@ -306,7 +306,7 @@ Hibernate would throw an exception because another person is still associated wi
Person person1 = entityManager.find(Person.class, personId); Person person1 = entityManager.find(Person.class, personId);
entityManager.remove(person1); entityManager.remove(person1);
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement Caused by: jakarta.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
Caused by: java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: foreign key no action; FKM7J0BNABH2YR0PE99IL1D066U table: PERSON_ADDRESS Caused by: java.sql.SQLIntegrityConstraintViolationException: integrity constraint violation: foreign key no action; FKM7J0BNABH2YR0PE99IL1D066U table: PERSON_ADDRESS
---- ----

View File

@ -47,7 +47,7 @@ The JPA specification strictly limits the Java types that can be marked as basic
If provider portability is a concern, you should stick to just these basic types. If provider portability is a concern, you should stick to just these basic types.
JPA 2.1 introduced the `javax.persistence.AttributeConverter` providing support for handling JPA 2.1 introduced the `jakarta.persistence.AttributeConverter` providing support for handling
types beyond those defined in the specification. See <<basic-jpa-convert>> for more on this topic. types beyond those defined in the specification. See <<basic-jpa-convert>> for more on this topic.
==== ====
@ -69,7 +69,7 @@ This chapter covers how Hibernate determines these pieces and how to influence t
[[basic-basic-annotation]] [[basic-basic-annotation]]
==== @Basic ==== @Basic
Strictly speaking, a basic type is denoted by the `javax.persistence.Basic` annotation. Strictly speaking, a basic type is denoted by the `jakarta.persistence.Basic` annotation.
Generally, the `@Basic` annotation can be ignored as it is assumed by default. Both of the following Generally, the `@Basic` annotation can be ignored as it is assumed by default. Both of the following
examples are ultimately the same. examples are ultimately the same.
@ -1381,7 +1381,7 @@ Hibernate supports the mapping of Java enums as basic value types in a number of
[[basic-enums-Enumerated]] [[basic-enums-Enumerated]]
===== `@Enumerated` ===== `@Enumerated`
The original JPA-compliant way to map enums was via the `@Enumerated` or `@MapKeyEnumerated` annotations, working on the principle that the enum values are stored according to one of 2 strategies indicated by `javax.persistence.EnumType`: The original JPA-compliant way to map enums was via the `@Enumerated` or `@MapKeyEnumerated` annotations, working on the principle that the enum values are stored according to one of 2 strategies indicated by `jakarta.persistence.EnumType`:
`ORDINAL`:: `ORDINAL`::
stored according to the enum value's ordinal position within the enum class, as indicated by `java.lang.Enum#ordinal` stored according to the enum value's ordinal position within the enum class, as indicated by `java.lang.Enum#ordinal`

View File

@ -21,7 +21,7 @@ Throughout this chapter and thereafter, entity types will be simply referred to
Section _2.1 The Entity Class_ of the _JPA 2.1 specification_ defines its requirements for an entity class. Section _2.1 The Entity Class_ of the _JPA 2.1 specification_ defines its requirements for an entity class.
Applications that wish to remain portable across JPA providers should adhere to these requirements: Applications that wish to remain portable across JPA providers should adhere to these requirements:
* The entity class must be annotated with the `javax.persistence.Entity` annotation (or be denoted as such in XML mapping). * The entity class must be annotated with the `jakarta.persistence.Entity` annotation (or be denoted as such in XML mapping).
* The entity class must have a public or protected no-argument constructor. It may define additional constructors as well. * The entity class must have a public or protected no-argument constructor. It may define additional constructors as well.
* The entity class must be a top-level class. * The entity class must be a top-level class.
* An enum or interface may not be designated as an entity. * An enum or interface may not be designated as an entity.
@ -114,7 +114,7 @@ Hibernate offers multiple identifier generation strategies, see the <<chapters/d
[[entity-pojo-mapping]] [[entity-pojo-mapping]]
==== Mapping the entity ==== Mapping the entity
The main piece in mapping the entity is the {jpaJavadocUrlPrefix}Entity.html[`javax.persistence.Entity`] annotation. The main piece in mapping the entity is the {jpaJavadocUrlPrefix}Entity.html[`jakarta.persistence.Entity`] annotation.
The `@Entity` annotation defines just the {jpaJavadocUrlPrefix}Entity.html#name--[`name`] attribute which is used to give a specific entity name for use in JPQL queries. The `@Entity` annotation defines just the {jpaJavadocUrlPrefix}Entity.html#name--[`name`] attribute which is used to give a specific entity name for use in JPQL queries.
@ -152,7 +152,7 @@ include::{sourcedir-mapping}/identifier/SimpleEntityTest.java[tag=entity-pojo-ma
An entity models a database table. An entity models a database table.
The identifier uniquely identifies each row in that table. The identifier uniquely identifies each row in that table.
By default, the name of the table is assumed to be the same as the name of the entity. By default, the name of the table is assumed to be the same as the name of the entity.
To explicitly give the name of the table or to specify other information about the table, we would use the `javax.persistence.Table` annotation. To explicitly give the name of the table or to specify other information about the table, we would use the `jakarta.persistence.Table` annotation.
[[entity-pojo-table-mapping-example]] [[entity-pojo-table-mapping-example]]
.Simple `@Entity` with `@Table` .Simple `@Entity` with `@Table`

View File

@ -1,6 +1,6 @@
javax.persistence.RollbackException: Error while committing the transaction jakarta.persistence.RollbackException: Error while committing the transaction
Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Caused by: jakarta.persistence.PersistenceException: org.hibernate.HibernateException:
Caused by: org.hibernate.HibernateException: changed an immutable collection instance: [ Caused by: org.hibernate.HibernateException: changed an immutable collection instance: [
org.hibernate.userguide.immutability.CollectionImmutabilityTest$Batch.events#1 org.hibernate.userguide.immutability.CollectionImmutabilityTest$Batch.events#1

View File

@ -31,7 +31,7 @@ An identifier might be simple (single value) or composite (multiple values).
[[identifiers-simple]] [[identifiers-simple]]
==== Simple identifiers ==== Simple identifiers
Simple identifiers map to a single basic attribute, and are denoted using the `javax.persistence.Id` annotation. Simple identifiers map to a single basic attribute, and are denoted using the `jakarta.persistence.Id` annotation.
According to JPA only the following types should be used as identifier attribute types: According to JPA only the following types should be used as identifier attribute types:
@ -63,7 +63,7 @@ include::{sourcedir}/AssignedIdentifierTest.java[tag=identifiers-simple-assigned
[[identifiers-simple-generated]] [[identifiers-simple-generated]]
===== Generated identifiers ===== Generated identifiers
Values for simple identifiers can be generated. To denote that an identifier attribute is generated, it is annotated with `javax.persistence.GeneratedValue` Values for simple identifiers can be generated. To denote that an identifier attribute is generated, it is annotated with `jakarta.persistence.GeneratedValue`
[[identifiers-simple-generated-mapping-example]] [[identifiers-simple-generated-mapping-example]]
.Simple generated identifier .Simple generated identifier
@ -87,8 +87,8 @@ Composite identifiers correspond to one or more persistent attributes.
Here are the rules governing composite identifiers, as defined by the JPA specification: Here are the rules governing composite identifiers, as defined by the JPA specification:
* The composite identifier must be represented by a "primary key class". * The composite identifier must be represented by a "primary key class".
The primary key class may be defined using the `javax.persistence.EmbeddedId` annotation (see <<identifiers-composite-aggregated>>), The primary key class may be defined using the `jakarta.persistence.EmbeddedId` annotation (see <<identifiers-composite-aggregated>>),
or defined using the `javax.persistence.IdClass` annotation (see <<identifiers-composite-nonaggregated>>). or defined using the `jakarta.persistence.IdClass` annotation (see <<identifiers-composite-nonaggregated>>).
* The primary key class must be public and must have a public no-arg constructor. * The primary key class must be public and must have a public no-arg constructor.
* The primary key class must be serializable. * The primary key class must be serializable.
* The primary key class must define equals and hashCode methods, consistent with equality for the underlying database types to which the primary key is mapped. * The primary key class must define equals and hashCode methods, consistent with equality for the underlying database types to which the primary key is mapped.
@ -283,8 +283,8 @@ You can also auto-generate values for non-identifier attributes. For more detail
Hibernate supports identifier value generation across a number of different types. Hibernate supports identifier value generation across a number of different types.
Remember that JPA portably defines identifier value generation just for integer types. Remember that JPA portably defines identifier value generation just for integer types.
Identifier value generation is indicated using the `javax.persistence.GeneratedValue` annotation. Identifier value generation is indicated using the `jakarta.persistence.GeneratedValue` annotation.
The most important piece of information here is the specified `javax.persistence.GenerationType` which indicates how values will be generated. The most important piece of information here is the specified `jakarta.persistence.GenerationType` which indicates how values will be generated.
[NOTE] [NOTE]
==== ====
@ -348,7 +348,7 @@ It is important to note that SequenceStyleGenerator is capable of working agains
This gives Hibernate a huge degree of portability across databases while still maintaining consistent id generation behavior (versus say choosing between SEQUENCE and IDENTITY). This gives Hibernate a huge degree of portability across databases while still maintaining consistent id generation behavior (versus say choosing between SEQUENCE and IDENTITY).
This backing storage is completely transparent to the user. This backing storage is completely transparent to the user.
The preferred (and portable) way to configure this generator is using the JPA-defined `javax.persistence.SequenceGenerator` annotation. The preferred (and portable) way to configure this generator is using the JPA-defined `jakarta.persistence.SequenceGenerator` annotation.
The simplest form is to simply request sequence generation; Hibernate will use a single, implicitly-named sequence (`hibernate_sequence`) for all such unnamed definitions. The simplest form is to simply request sequence generation; Hibernate will use a single, implicitly-named sequence (`hibernate_sequence`) for all such unnamed definitions.
@ -361,7 +361,7 @@ include::{sourcedir}/SequenceGeneratorUnnamedTest.java[tag=identifiers-generator
---- ----
==== ====
Using `javax.persistence.SequenceGenerator`, you can specify a specific database sequence name. Using `jakarta.persistence.SequenceGenerator`, you can specify a specific database sequence name.
[[identifiers-generators-sequence-named]] [[identifiers-generators-sequence-named]]
.Named sequence .Named sequence
@ -372,7 +372,7 @@ include::{sourcedir}/SequenceGeneratorNamedTest.java[tag=identifiers-generators-
---- ----
==== ====
The `javax.persistence.SequenceGenerator` annotation allows you to specify additional configurations as well. The `jakarta.persistence.SequenceGenerator` annotation allows you to specify additional configurations as well.
[[identifiers-generators-sequence-configured]] [[identifiers-generators-sequence-configured]]
.Configured sequence .Configured sequence
@ -434,7 +434,7 @@ include::{extrasdir}/id/identifiers-generators-table-unnamed-mapping-example.sql
If no table name is given Hibernate assumes an implicit name of `hibernate_sequences`. If no table name is given Hibernate assumes an implicit name of `hibernate_sequences`.
Additionally, because no `javax.persistence.TableGenerator#pkColumnValue` is specified, Additionally, because no `jakarta.persistence.TableGenerator#pkColumnValue` is specified,
Hibernate will use the default segment (`sequence_name='default'`) from the hibernate_sequences table. Hibernate will use the default segment (`sequence_name='default'`) from the hibernate_sequences table.
However, you can configure the table identifier generator using the {jpaJavadocUrlPrefix}TableGenerator.html[`@TableGenerator`] annotation. However, you can configure the table identifier generator using the {jpaJavadocUrlPrefix}TableGenerator.html[`@TableGenerator`] annotation.

View File

@ -114,7 +114,7 @@ Use the `@DiscriminatorColumn` to define the discriminator column as well as the
[NOTE] [NOTE]
==== ====
The enum `DiscriminatorType` used in `javax.persistence.DiscriminatorColumn` only contains the values `STRING`, `CHAR` and `INTEGER` which means that not all Hibernate supported types are available via the `@DiscriminatorColumn` annotation. The enum `DiscriminatorType` used in `jakarta.persistence.DiscriminatorColumn` only contains the values `STRING`, `CHAR` and `INTEGER` which means that not all Hibernate supported types are available via the `@DiscriminatorColumn` annotation.
You can also use `@DiscriminatorFormula` to express in SQL a virtual discriminator column. You can also use `@DiscriminatorFormula` to express in SQL a virtual discriminator column.
This is particularly useful when the discriminator value can be extracted from one or more columns of the table. This is particularly useful when the discriminator value can be extracted from one or more columns of the table.
Both `@DiscriminatorColumn` and `@DiscriminatorFormula` are to be set on the root entity (once per persisted hierarchy). Both `@DiscriminatorColumn` and `@DiscriminatorFormula` are to be set on the root entity (once per persisted hierarchy).

View File

@ -340,7 +340,7 @@ please see <<envers-mappingexceptions>> for a description of the additional `@Au
If you want to audit a relation, where the target entity is not audited (that is the case for example with dictionary-like entities, which don't change and don't have to be audited), If you want to audit a relation, where the target entity is not audited (that is the case for example with dictionary-like entities, which don't change and don't have to be audited),
just annotate it with `@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )`. just annotate it with `@Audited( targetAuditMode = RelationTargetAuditMode.NOT_AUDITED )`.
Then, while reading historic versions of your entity, the relation will always point to the "current" related entity. Then, while reading historic versions of your entity, the relation will always point to the "current" related entity.
By default Envers throws `javax.persistence.EntityNotFoundException` when "current" entity does not exist in the database. By default Envers throws `jakarta.persistence.EntityNotFoundException` when "current" entity does not exist in the database.
Apply `@NotFound( action = NotFoundAction.IGNORE )` annotation to silence the exception and assign null value instead. Apply `@NotFound( action = NotFoundAction.IGNORE )` annotation to silence the exception and assign null value instead.
The hereby solution causes implicit eager loading of to-one relations. The hereby solution causes implicit eager loading of to-one relations.
@ -1431,7 +1431,7 @@ Although Hibernate allows this, Envers (or more precisely the database connector
There are at least two ways out if you need bag semantics: There are at least two ways out if you need bag semantics:
. use an indexed collection, with the `@javax.persistence.OrderColumn` annotation. . use an indexed collection, with the `@jakarta.persistence.OrderColumn` annotation.
. provide a unique id for your elements with the `@CollectionId` annotation. . provide a unique id for your elements with the `@CollectionId` annotation.
==== What isn't and _will_ be supported ==== What isn't and _will_ be supported

View File

@ -144,7 +144,7 @@ There are two available approaches defined for specifying callback handling:
* The second is to use a separate entity listener class. * The second is to use a separate entity listener class.
An entity listener is a stateless class with a no-arg constructor. An entity listener is a stateless class with a no-arg constructor.
The callback annotations are placed on a method of this class instead of the entity class. The callback annotations are placed on a method of this class instead of the entity class.
The entity listener class is then associated with the entity using the `javax.persistence.EntityListeners` annotation The entity listener class is then associated with the entity using the `jakarta.persistence.EntityListeners` annotation
[[events-jpa-callbacks-example]] [[events-jpa-callbacks-example]]
.Example of specifying JPA callbacks .Example of specifying JPA callbacks
@ -170,10 +170,10 @@ A callback method must not invoke `EntityManager` or `Query` methods!
It is possible that multiple callback methods are defined for a particular lifecycle event. It is possible that multiple callback methods are defined for a particular lifecycle event.
When that is the case, the defined order of execution is well defined by the JPA spec (specifically section 3.5.4): When that is the case, the defined order of execution is well defined by the JPA spec (specifically section 3.5.4):
* Any default listeners associated with the entity are invoked first, in the order they were specified in the XML. See the `javax.persistence.ExcludeDefaultListeners` annotation. * Any default listeners associated with the entity are invoked first, in the order they were specified in the XML. See the `jakarta.persistence.ExcludeDefaultListeners` annotation.
* Next, entity listener class callbacks associated with the entity hierarchy are invoked, in the order they are defined in the `EntityListeners`. * Next, entity listener class callbacks associated with the entity hierarchy are invoked, in the order they are defined in the `EntityListeners`.
If multiple classes in the entity hierarchy define entity listeners, the listeners defined for a superclass are invoked before the listeners defined for its subclasses. If multiple classes in the entity hierarchy define entity listeners, the listeners defined for a superclass are invoked before the listeners defined for its subclasses.
See the ``javax.persistence.ExcludeSuperclassListener``'s annotation. See the ``jakarta.persistence.ExcludeSuperclassListener``'s annotation.
* Lastly, callback methods defined on the entity hierarchy are invoked. * Lastly, callback methods defined on the entity hierarchy are invoked.
If a callback type is annotated on both an entity and one or more of its superclasses without method overriding, both would be called, the most general superclass first. If a callback type is annotated on both an entity and one or more of its superclasses without method overriding, both would be called, the most general superclass first.
An entity class is also allowed to override a callback method defined in a superclass in which case the super callback would not get invoked; the overriding method would get invoked provided it is annotated. An entity class is also allowed to override a callback method defined in a superclass in which case the super callback would not get invoked; the overriding method would get invoked provided it is annotated.

View File

@ -358,7 +358,7 @@ creates a single AttributeNode with 3 distinct SubGraphs. It is functionally th
[source, JAVA, indent=0] [source, JAVA, indent=0]
---- ----
Class<Invoice> invoiceClass = ...; Class<Invoice> invoiceClass = ...;
javax.persistence.EntityGraph<Invoice> invoiceGraph = entityManager.createEntityGraph( invoiceClass ); jakarta.persistence.EntityGraph<Invoice> invoiceGraph = entityManager.createEntityGraph( invoiceClass );
invoiceGraph.addAttributeNode( "responsibleParty" ); invoiceGraph.addAttributeNode( "responsibleParty" );
invoiceGraph.addSubgraph( "responsibleParty" ).addAttributeNode( "taxIdNumber" ); invoiceGraph.addSubgraph( "responsibleParty" ).addAttributeNode( "taxIdNumber" );
invoiceGraph.addSubgraph( "responsibleParty", Corporation.class ).addAttributeNode( "ceo" ); invoiceGraph.addSubgraph( "responsibleParty", Corporation.class ).addAttributeNode( "ceo" );

View File

@ -32,7 +32,8 @@ For cases where a JNDI name is given, be sure to read <<chapters/jndi/JNDI.adoc#
[NOTE] [NOTE]
==== ====
For JPA applications, note that `hibernate.connection.datasource` corresponds to either `javax.persistence.jtaDataSource` or `javax.persistence.nonJtaDataSource`. For JPA applications, note that `hibernate.connection.datasource` corresponds to
`jakarta.persistence.jtaDataSource` or `jakarta.persistence.nonJtaDataSource`.
==== ====
The `DataSource` `ConnectionProvider` also (optionally) accepts the `hibernate.connection.username` and `hibernate.connection.password`. The `DataSource` `ConnectionProvider` also (optionally) accepts the `hibernate.connection.username` and `hibernate.connection.password`.

View File

@ -40,7 +40,7 @@ especially useful if you use assigned identifiers or composite keys.
==== Mapping optimistic locking ==== Mapping optimistic locking
JPA defines support for optimistic locking based on either a version (sequential numeric) or timestamp strategy. JPA defines support for optimistic locking based on either a version (sequential numeric) or timestamp strategy.
To enable this style of optimistic locking simply add the `javax.persistence.Version` to the persistent attribute that defines the optimistic locking value. To enable this style of optimistic locking simply add the `jakarta.persistence.Version` to the persistent attribute that defines the optimistic locking value.
According to JPA, the valid types for these attributes are limited to: According to JPA, the valid types for these attributes are limited to:
* `int` or `Integer` * `int` or `Integer`
@ -324,8 +324,8 @@ JPA comes with its own {jpaJavadocUrlPrefix}LockModeType.html[`LockModeType`] en
|`PESSIMISTIC_FORCE_INCREMENT`|`PESSIMISTIC_FORCE_INCREMENT` | The entity is locked pessimistically and its version is incremented automatically even if the entity has not changed. |`PESSIMISTIC_FORCE_INCREMENT`|`PESSIMISTIC_FORCE_INCREMENT` | The entity is locked pessimistically and its version is incremented automatically even if the entity has not changed.
|`PESSIMISTIC_READ`|`PESSIMISTIC_READ` | The entity is locked pessimistically using a shared lock if the database supports such a feature. Otherwise, an explicit lock is used. |`PESSIMISTIC_READ`|`PESSIMISTIC_READ` | The entity is locked pessimistically using a shared lock if the database supports such a feature. Otherwise, an explicit lock is used.
|`PESSIMISTIC_WRITE`|`PESSIMISTIC_WRITE`, `UPGRADE` | The entity is locked using an explicit lock. |`PESSIMISTIC_WRITE`|`PESSIMISTIC_WRITE`, `UPGRADE` | The entity is locked using an explicit lock.
|`PESSIMISTIC_WRITE` with a `javax.persistence.lock.timeout` setting of 0 |`UPGRADE_NOWAIT` | The lock acquisition request fails fast if the row s already locked. |`PESSIMISTIC_WRITE` with a `jakarta.persistence.lock.timeout` setting of 0 |`UPGRADE_NOWAIT` | The lock acquisition request fails fast if the row s already locked.
|`PESSIMISTIC_WRITE` with a `javax.persistence.lock.timeout` setting of -2 |`UPGRADE_SKIPLOCKED` | The lock acquisition request skips the already locked rows. It uses a `SELECT ... FOR UPDATE SKIP LOCKED` in Oracle and PostgreSQL 9.5, or `SELECT ... with (rowlock, updlock, readpast) in SQL Server`. |`PESSIMISTIC_WRITE` with a `jakarta.persistence.lock.timeout` setting of -2 |`UPGRADE_SKIPLOCKED` | The lock acquisition request skips the already locked rows. It uses a `SELECT ... FOR UPDATE SKIP LOCKED` in Oracle and PostgreSQL 9.5, or `SELECT ... with (rowlock, updlock, readpast) in SQL Server`.
|======================================================================= |=======================================================================
The explicit user request mentioned above occurs as a consequence of any of the following actions: The explicit user request mentioned above occurs as a consequence of any of the following actions:
@ -350,12 +350,12 @@ This ensures that applications are portable.
JPA 2.0 introduced two query hints: JPA 2.0 introduced two query hints:
javax.persistence.lock.timeout:: it gives the number of milliseconds a lock acquisition request will wait before throwing an exception jakarta.persistence.lock.timeout:: it gives the number of milliseconds a lock acquisition request will wait before throwing an exception
javax.persistence.lock.scope:: defines the {jpaJavadocUrlPrefix}PessimisticLockScope.html[_scope_] of the lock acquisition request. jakarta.persistence.lock.scope:: defines the {jpaJavadocUrlPrefix}PessimisticLockScope.html[_scope_] of the lock acquisition request.
The scope can either be `NORMAL` (default value) or `EXTENDED`. The `EXTENDED` scope will cause a lock acquisition request to be passed to other owned table structured (e.g. `@Inheritance(strategy=InheritanceType.JOINED)`, `@ElementCollection`) The scope can either be `NORMAL` (default value) or `EXTENDED`. The `EXTENDED` scope will cause a lock acquisition request to be passed to other owned table structured (e.g. `@Inheritance(strategy=InheritanceType.JOINED)`, `@ElementCollection`)
[[locking-jpa-query-hints-timeout-example]] [[locking-jpa-query-hints-timeout-example]]
.`javax.persistence.lock.timeout` example .`jakarta.persistence.lock.timeout` example
==== ====
[source, JAVA,indent=0] [source, JAVA,indent=0]
---- ----
@ -376,7 +376,7 @@ If not supported, the Hibernate dialect ignores this query hint.
[NOTE] [NOTE]
==== ====
The `javax.persistence.lock.scope` is https://hibernate.atlassian.net/browse/HHH-9636[not yet supported] as specified by the JPA standard. The `jakarta.persistence.lock.scope` is https://hibernate.atlassian.net/browse/HHH-9636[not yet supported] as specified by the JPA standard.
==== ====
[[locking-buildLockRequest]] [[locking-buildLockRequest]]

View File

@ -4,7 +4,7 @@
:sourcedir-caching: ../../../../../test/java/org/hibernate/userguide/caching :sourcedir-caching: ../../../../../test/java/org/hibernate/userguide/caching
:extrasdir: extras :extrasdir: extras
Both the `org.hibernate.Session` API and `javax.persistence.EntityManager` API represent a context for dealing with persistent data. Both the `org.hibernate.Session` API and `jakarta.persistence.EntityManager` API represent a context for dealing with persistent data.
This concept is called a `persistence context`. This concept is called a `persistence context`.
Persistent data has a state in relation to both a persistence context and the underlying database. Persistent data has a state in relation to both a persistence context and the underlying database.
@ -15,7 +15,7 @@ It may or may not physically exist in the database yet.
`detached`:: the entity has an associated identifier but is no longer associated with a persistence context (usually because the persistence context was closed or the instance was evicted from the context) `detached`:: the entity has an associated identifier but is no longer associated with a persistence context (usually because the persistence context was closed or the instance was evicted from the context)
`removed`:: the entity has an associated identifier and is associated with a persistence context, however, it is scheduled for removal from the database. `removed`:: the entity has an associated identifier and is associated with a persistence context, however, it is scheduled for removal from the database.
Much of the `org.hibernate.Session` and `javax.persistence.EntityManager` methods deal with moving entities among these states. Much of the `org.hibernate.Session` and `jakarta.persistence.EntityManager` methods deal with moving entities among these states.
[[pc-unwrap]] [[pc-unwrap]]
=== Accessing Hibernate APIs from JPA === Accessing Hibernate APIs from JPA
@ -37,7 +37,7 @@ include::BytecodeEnhancement.adoc[]
=== Making entities persistent === Making entities persistent
Once you've created a new entity instance (using the standard `new` operator) it is in `new` state. Once you've created a new entity instance (using the standard `new` operator) it is in `new` state.
You can make it persistent by associating it to either an `org.hibernate.Session` or a `javax.persistence.EntityManager`. You can make it persistent by associating it to either an `org.hibernate.Session` or a `jakarta.persistence.EntityManager`.
[[pc-persist-jpa-example]] [[pc-persist-jpa-example]]
.Making an entity persistent with JPA .Making an entity persistent with JPA
@ -58,7 +58,7 @@ include::{sourcedir}/PersistenceContextTest.java[tags=pc-persist-native-example]
==== ====
`org.hibernate.Session` also has a method named persist which follows the exact semantics defined in the JPA specification for the persist method. `org.hibernate.Session` also has a method named persist which follows the exact semantics defined in the JPA specification for the persist method.
It is this `org.hibernate.Session` method to which the Hibernate `javax.persistence.EntityManager` implementation delegates. It is this `org.hibernate.Session` method to which the Hibernate `jakarta.persistence.EntityManager` implementation delegates.
If the `DomesticCat` entity type has a generated identifier, the value is associated with the instance when the save or persist is called. If the `DomesticCat` entity type has a generated identifier, the value is associated with the instance when the save or persist is called.
If the identifier is not automatically generated, the manually assigned (usually natural) key value has to be set on the instance before the save or persist methods are called. If the identifier is not automatically generated, the manually assigned (usually natural) key value has to be set on the instance before the save or persist methods are called.
@ -92,7 +92,7 @@ Hibernate itself can handle deleting entities in detached state.
JPA, however, disallows this behavior. JPA, however, disallows this behavior.
The implication here is that the entity instance passed to the `org.hibernate.Session` delete method can be either in managed or detached state, The implication here is that the entity instance passed to the `org.hibernate.Session` delete method can be either in managed or detached state,
while the entity instance passed to remove on `javax.persistence.EntityManager` must be in the managed state. while the entity instance passed to remove on `jakarta.persistence.EntityManager` must be in the managed state.
==== ====
[[pc-get-reference]] [[pc-get-reference]]
@ -1069,7 +1069,7 @@ include::{sourcedir}/PersistenceContextTest.java[tags=pc-verify-lazy-native-exam
---- ----
==== ====
In JPA there is an alternative means to check laziness using the following `javax.persistence.PersistenceUtil` pattern (which is recommended wherever possible). In JPA there is an alternative means to check laziness using the following `jakarta.persistence.PersistenceUtil` pattern (which is recommended wherever possible).
[[pc-verify-lazy-jpa-alternative-example]] [[pc-verify-lazy-jpa-alternative-example]]
.Alternative JPA means to verify laziness .Alternative JPA means to verify laziness
@ -1130,7 +1130,7 @@ include::{sourcedir-caching}/FirstLevelCacheTest.java[tags=caching-management-co
=== Cascading entity state transitions === Cascading entity state transitions
JPA allows you to propagate the state transition from a parent entity to a child. JPA allows you to propagate the state transition from a parent entity to a child.
For this purpose, the JPA `javax.persistence.CascadeType` defines various cascade types: For this purpose, the JPA `jakarta.persistence.CascadeType` defines various cascade types:
`ALL`:: cascades all entity state transitions. `ALL`:: cascades all entity state transitions.
`PERSIST`:: cascades the entity persist operation. `PERSIST`:: cascades the entity persist operation.
@ -1236,7 +1236,7 @@ include::{sourcedir}/CascadeDetachTest.java[tags=pc-cascade-detach-example]
==== `CascadeType.LOCK` ==== `CascadeType.LOCK`
Although unintuitively, `CascadeType.LOCK` does not propagate a lock request from a parent entity to its children. Although unintuitively, `CascadeType.LOCK` does not propagate a lock request from a parent entity to its children.
Such a use case requires the use of the `PessimisticLockScope.EXTENDED` value of the `javax.persistence.lock.scope` property. Such a use case requires the use of the `PessimisticLockScope.EXTENDED` value of the `jakarta.persistence.lock.scope` property.
However, `CascadeType.LOCK` allows us to reattach a parent entity along with its children to the currently running Persistence Context. However, `CascadeType.LOCK` allows us to reattach a parent entity along with its children to the currently running Persistence Context.

View File

@ -8,7 +8,7 @@ Criteria queries offer a type-safe alternative to HQL, JPQL and native SQL queri
==== ====
Hibernate offers an older, legacy `org.hibernate.Criteria` API which should be considered deprecated. Hibernate offers an older, legacy `org.hibernate.Criteria` API which should be considered deprecated.
No feature development will target those APIs. Eventually, Hibernate-specific Criteria features will be ported as extensions to the JPA `javax.persistence.criteria.CriteriaQuery`. No feature development will target those APIs. Eventually, Hibernate-specific Criteria features will be ported as extensions to the JPA `jakarta.persistence.criteria.CriteriaQuery`.
For details on the `org.hibernate.Criteria` API, see <<appendices/Legacy_Criteria.adoc#appendix-legacy-criteria, Legacy Hibernate Criteria Queries>>. For details on the `org.hibernate.Criteria` API, see <<appendices/Legacy_Criteria.adoc#appendix-legacy-criteria, Legacy Hibernate Criteria Queries>>.
This chapter will focus on the JPA APIs for declaring type-safe criteria queries. This chapter will focus on the JPA APIs for declaring type-safe criteria queries.
@ -21,12 +21,12 @@ Users of the older Hibernate `org.hibernate.Criteria` query API will recognize t
Criteria queries are essentially an object graph, where each part of the graph represents an increasing (as we navigate down this graph) more atomic part of the query. Criteria queries are essentially an object graph, where each part of the graph represents an increasing (as we navigate down this graph) more atomic part of the query.
The first step in performing a criteria query is building this graph. The first step in performing a criteria query is building this graph.
The `javax.persistence.criteria.CriteriaBuilder` interface is the first thing with which you need to become acquainted with before using criteria queries. The `jakarta.persistence.criteria.CriteriaBuilder` interface is the first thing with which you need to become acquainted with before using criteria queries.
Its role is that of a factory for all the individual pieces of the criteria. Its role is that of a factory for all the individual pieces of the criteria.
You obtain a `javax.persistence.criteria.CriteriaBuilder` instance by calling the `getCriteriaBuilder()` method of either `javax.persistence.EntityManagerFactory` or `javax.persistence.EntityManager`. You obtain a `jakarta.persistence.criteria.CriteriaBuilder` instance by calling the `getCriteriaBuilder()` method of either `jakarta.persistence.EntityManagerFactory` or `jakarta.persistence.EntityManager`.
The next step is to obtain a `javax.persistence.criteria.CriteriaQuery`. The next step is to obtain a `jakarta.persistence.criteria.CriteriaQuery`.
This is accomplished using one of the three methods on `javax.persistence.criteria.CriteriaBuilder` for this purpose: This is accomplished using one of the three methods on `jakarta.persistence.criteria.CriteriaBuilder` for this purpose:
* `<T> CriteriaQuery<T> createQuery( Class<T> resultClass )` * `<T> CriteriaQuery<T> createQuery( Class<T> resultClass )`
* `CriteriaQuery<Tuple> createTupleQuery()` * `CriteriaQuery<Tuple> createTupleQuery()`
@ -111,7 +111,7 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-typedquery-multiselect-arra
Technically this is classified as a typed query, but you can see from handling the results that this is sort of misleading. Technically this is classified as a typed query, but you can see from handling the results that this is sort of misleading.
Anyway, the expected result type here is an array. Anyway, the expected result type here is an array.
The example then uses the array method of `javax.persistence.criteria.CriteriaBuilder` which explicitly combines individual selections into a `javax.persistence.criteria.CompoundSelection`. The example then uses the array method of `jakarta.persistence.criteria.CriteriaBuilder` which explicitly combines individual selections into a `jakarta.persistence.criteria.CompoundSelection`.
[[criteria-typedquery-multiselect-array-implicit-example]] [[criteria-typedquery-multiselect-array-implicit-example]]
.Selecting an array using `multiselect` .Selecting an array using `multiselect`
@ -148,14 +148,14 @@ First, we see the simple definition of the wrapper object we will be using to wr
Specifically, notice the constructor and its argument types. Specifically, notice the constructor and its argument types.
Since we will be returning `PersonWrapper` objects, we use `PersonWrapper` as the type of our criteria query. Since we will be returning `PersonWrapper` objects, we use `PersonWrapper` as the type of our criteria query.
This example illustrates the use of the `javax.persistence.criteria.CriteriaBuilder` method construct which is used to build a wrapper expression. This example illustrates the use of the `jakarta.persistence.criteria.CriteriaBuilder` method construct which is used to build a wrapper expression.
For every row in the result, we are saying we would like a `PersonWrapper` instantiated with the remaining arguments by the matching constructor. For every row in the result, we are saying we would like a `PersonWrapper` instantiated with the remaining arguments by the matching constructor.
This wrapper expression is then passed as the select. This wrapper expression is then passed as the select.
[[criteria-tuple]] [[criteria-tuple]]
=== Tuple criteria queries === Tuple criteria queries
A better approach to <<criteria-typedquery-multiselect>> is to use either a wrapper (which we just saw in <<criteria-typedquery-wrapper>>) or using the `javax.persistence.Tuple` contract. A better approach to <<criteria-typedquery-multiselect>> is to use either a wrapper (which we just saw in <<criteria-typedquery-wrapper>>) or using the `jakarta.persistence.Tuple` contract.
[[criteria-tuple-example]] [[criteria-tuple-example]]
.Selecting a tuple .Selecting a tuple
@ -166,18 +166,18 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-tuple-example]
---- ----
==== ====
This example illustrates accessing the query results through the `javax.persistence.Tuple` interface. This example illustrates accessing the query results through the `jakarta.persistence.Tuple` interface.
The example uses the explicit `createTupleQuery()` of `javax.persistence.criteria.CriteriaBuilder`. The example uses the explicit `createTupleQuery()` of `jakarta.persistence.criteria.CriteriaBuilder`.
An alternate approach is to use `createQuery( Tuple.class )`. An alternate approach is to use `createQuery( Tuple.class )`.
Again we see the use of the `multiselect()` method, just like in <<criteria-typedquery-multiselect-array-implicit-example>>. Again we see the use of the `multiselect()` method, just like in <<criteria-typedquery-multiselect-array-implicit-example>>.
The difference here is that the type of the `javax.persistence.criteria.CriteriaQuery` was defined as `javax.persistence.Tuple` so the compound selections, in this case, are interpreted to be the tuple elements. The difference here is that the type of the `jakarta.persistence.criteria.CriteriaQuery` was defined as `jakarta.persistence.Tuple` so the compound selections, in this case, are interpreted to be the tuple elements.
The javax.persistence.Tuple contract provides three forms of access to the underlying elements: The jakarta.persistence.Tuple contract provides three forms of access to the underlying elements:
typed:: typed::
The <<criteria-tuple-example>> example illustrates this form of access in the `tuple.get( idPath )` and `tuple.get( nickNamePath )` calls. The <<criteria-tuple-example>> example illustrates this form of access in the `tuple.get( idPath )` and `tuple.get( nickNamePath )` calls.
This allows typed access to the underlying tuple values based on the `javax.persistence.TupleElement` expressions used to build the criteria. This allows typed access to the underlying tuple values based on the `jakarta.persistence.TupleElement` expressions used to build the criteria.
positional:: positional::
Allows access to the underlying tuple values based on the position. Allows access to the underlying tuple values based on the position.
The simple _Object get(int position)_ form is very similar to the access illustrated in <<criteria-typedquery-multiselect-array-explicit-example>> and <<criteria-typedquery-multiselect-array-implicit-example>>. The simple _Object get(int position)_ form is very similar to the access illustrated in <<criteria-typedquery-multiselect-array-explicit-example>> and <<criteria-typedquery-multiselect-array-implicit-example>>.
@ -185,7 +185,7 @@ positional::
aliased:: aliased::
Allows access to the underlying tuple values based on (optionally) assigned alias. Allows access to the underlying tuple values based on (optionally) assigned alias.
The example query did not apply an alias. The example query did not apply an alias.
An alias would be applied via the alias method on `javax.persistence.criteria.Selection`. An alias would be applied via the alias method on `jakarta.persistence.criteria.Selection`.
Just like `positional` access, there is both a typed (__Object get(String alias)__) and an untyped (__<X> X get(String alias, Class<X> type)__) form. Just like `positional` access, there is both a typed (__Object get(String alias)__) and an untyped (__<X> X get(String alias, Class<X> type)__) form.
[[criteria-from]] [[criteria-from]]
@ -200,14 +200,14 @@ The root objects of the query are entities, from which the other types are reach
[NOTE] [NOTE]
==== ====
All the individual parts of the FROM clause (roots, joins, paths) implement the `javax.persistence.criteria.From` interface. All the individual parts of the FROM clause (roots, joins, paths) implement the `jakarta.persistence.criteria.From` interface.
==== ====
[[criteria-from-root]] [[criteria-from-root]]
=== Roots === Roots
Roots define the basis from which all joins, paths and attributes are available in the query. Roots define the basis from which all joins, paths and attributes are available in the query.
A root is always an entity type. Roots are defined and added to the criteria by the overloaded __from__ methods on `javax.persistence.criteria.CriteriaQuery`: A root is always an entity type. Roots are defined and added to the criteria by the overloaded __from__ methods on `jakarta.persistence.criteria.CriteriaQuery`:
[[criteria-from-root-methods-example]] [[criteria-from-root-methods-example]]
.Root methods .Root methods
@ -244,8 +244,8 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-from-multiple-root-example]
[[criteria-from-join]] [[criteria-from-join]]
=== Joins === Joins
Joins allow navigation from other `javax.persistence.criteria.From` to either association or embedded attributes. Joins allow navigation from other `jakarta.persistence.criteria.From` to either association or embedded attributes.
Joins are created by the numerous overloaded __join__ methods of the `javax.persistence.criteria.From` interface. Joins are created by the numerous overloaded __join__ methods of the `jakarta.persistence.criteria.From` interface.
[[criteria-from-join-example]] [[criteria-from-join-example]]
.Join example .Join example
@ -260,7 +260,7 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-from-join-example]
=== Fetches === Fetches
Just like in HQL and JPQL, criteria queries can specify that associated data be fetched along with the owner. Just like in HQL and JPQL, criteria queries can specify that associated data be fetched along with the owner.
Fetches are created by the numerous overloaded __fetch__ methods of the `javax.persistence.criteria.From` interface. Fetches are created by the numerous overloaded __fetch__ methods of the `jakarta.persistence.criteria.From` interface.
[[criteria-from-fetch-example]] [[criteria-from-fetch-example]]
.Join fetch example .Join fetch example
@ -274,7 +274,7 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-from-fetch-example]
[NOTE] [NOTE]
==== ====
Technically speaking, embedded attributes are always fetched with their owner. Technically speaking, embedded attributes are always fetched with their owner.
However, in order to define the fetching of _Phone#addresses_ we needed a `javax.persistence.criteria.Fetch` because element collections are `LAZY` by default. However, in order to define the fetching of _Phone#addresses_ we needed a `jakarta.persistence.criteria.Fetch` because element collections are `LAZY` by default.
==== ====
[[criteria-path]] [[criteria-path]]
@ -297,8 +297,8 @@ include::{sourcedir}/CriteriaTest.java[tags=criteria-param-example]
---- ----
==== ====
Use the parameter method of `javax.persistence.criteria.CriteriaBuilder` to obtain a parameter reference. Use the parameter method of `jakarta.persistence.criteria.CriteriaBuilder` to obtain a parameter reference.
Then use the parameter reference to bind the parameter value to the `javax.persistence.Query`. Then use the parameter reference to bind the parameter value to the `jakarta.persistence.Query`.
[[criteria-group-by]] [[criteria-group-by]]
=== Using group by === Using group by

View File

@ -46,14 +46,14 @@ include::{modeldir}/WireTransferPayment.java[tags=hql-examples-domain-model-exam
When using Hibernate, you can execute entity queries either via JPA or the Hibernate-specific API. When using Hibernate, you can execute entity queries either via JPA or the Hibernate-specific API.
Since 5.2, the Hibernate `Session` interface extends the JPA `EntityManager` interface. Since 5.2, the Hibernate `Session` interface extends the JPA `EntityManager` interface.
For this reason, the query API was also merged, and now the Hibernate `org.hibernate.query.Query` interface extends the JPA `javax.persistence.Query`. For this reason, the query API was also merged, and now the Hibernate `org.hibernate.query.Query` interface extends the JPA `jakarta.persistence.Query`.
Next, we are going to see how the query API differs between the standard JPA interfaces and the Hibernate-specific API. Next, we are going to see how the query API differs between the standard JPA interfaces and the Hibernate-specific API.
[[jpql-api]] [[jpql-api]]
==== JPA Query API ==== JPA Query API
In JPA, the query is represented by `javax.persistence.Query` or `javax.persistence.TypedQuery` as obtained from the `EntityManager`. In JPA, the query is represented by `jakarta.persistence.Query` or `jakarta.persistence.TypedQuery` as obtained from the `EntityManager`.
The create an inline `Query` or `TypedQuery`, you need to use the `EntityManager#createQuery` method. The create an inline `Query` or `TypedQuery`, you need to use the `EntityManager#createQuery` method.
For named queries, the `EntityManager#createNamedQuery` method is needed. For named queries, the `EntityManager#createNamedQuery` method is needed.
@ -109,13 +109,13 @@ Many of the settings controlling the execution of the query are defined as hints
JPA defines some standard hints (like timeout in the example), but most are provider specific. JPA defines some standard hints (like timeout in the example), but most are provider specific.
Relying on provider specific hints limits your applications portability to some degree. Relying on provider specific hints limits your applications portability to some degree.
`javax.persistence.query.timeout`:: `jakarta.persistence.query.timeout`::
Defines the query timeout, in milliseconds. Defines the query timeout, in milliseconds.
`javax.persistence.fetchgraph`:: `jakarta.persistence.fetchgraph`::
Defines a _fetchgraph_ EntityGraph. Defines a _fetchgraph_ EntityGraph.
Attributes explicitly specified as `AttributeNodes` are treated as `FetchType.EAGER` (via join fetch or subsequent select). Attributes explicitly specified as `AttributeNodes` are treated as `FetchType.EAGER` (via join fetch or subsequent select).
For details, see the EntityGraph discussions in <<chapters/fetching/Fetching.adoc#fetching,Fetching>>. For details, see the EntityGraph discussions in <<chapters/fetching/Fetching.adoc#fetching,Fetching>>.
`javax.persistence.loadgraph`:: `jakarta.persistence.loadgraph`::
Defines a _loadgraph_ EntityGraph. Defines a _loadgraph_ EntityGraph.
Attributes explicitly specified as AttributeNodes are treated as `FetchType.EAGER` (via join fetch or subsequent select). Attributes explicitly specified as AttributeNodes are treated as `FetchType.EAGER` (via join fetch or subsequent select).
Attributes that are not specified are treated as `FetchType.LAZY` or `FetchType.EAGER` depending on the attribute's definition in metadata. Attributes that are not specified are treated as `FetchType.LAZY` or `FetchType.EAGER` depending on the attribute's definition in metadata.
@ -131,7 +131,7 @@ Relying on provider specific hints limits your applications portability to some
`org.hibernate.fetchSize`:: `org.hibernate.fetchSize`::
Defines the JDBC fetch-size to use. See `org.hibernate.query.Query#setFetchSize`. Defines the JDBC fetch-size to use. See `org.hibernate.query.Query#setFetchSize`.
`org.hibernate.flushMode`:: `org.hibernate.flushMode`::
Defines the Hibernate-specific `FlushMode` to use. See `org.hibernate.query.Query#setFlushMode.` If possible, prefer using `javax.persistence.Query#setFlushMode` instead. Defines the Hibernate-specific `FlushMode` to use. See `org.hibernate.query.Query#setFlushMode.` If possible, prefer using `jakarta.persistence.Query#setFlushMode` instead.
`org.hibernate.readOnly`:: Defines that entities and collections loaded by this query should be marked as read-only. See `org.hibernate.query.Query#setReadOnly`. `org.hibernate.readOnly`:: Defines that entities and collections loaded by this query should be marked as read-only. See `org.hibernate.query.Query#setReadOnly`.
The final thing that needs to happen before the query can be executed is to bind the values for any defined parameters. The final thing that needs to happen before the query can be executed is to bind the values for any defined parameters.
@ -542,7 +542,7 @@ Versioned updates is a Hibernate-specific feature and will not work in a portabl
Custom version types, `org.hibernate.usertype.UserVersionType`, are not allowed in conjunction with an `update versioned` statement. Custom version types, `org.hibernate.usertype.UserVersionType`, are not allowed in conjunction with an `update versioned` statement.
==== ====
An `UPDATE` statement is executed using the `executeUpdate()` of either `org.hibernate.query.Query` or `javax.persistence.Query`. An `UPDATE` statement is executed using the `executeUpdate()` of either `org.hibernate.query.Query` or `jakarta.persistence.Query`.
The method is named for those familiar with the JDBC `executeUpdate()` on `java.sql.PreparedStatement`. The method is named for those familiar with the JDBC `executeUpdate()` on `java.sql.PreparedStatement`.
The `int` value returned by the `executeUpdate()` method indicates the number of entities affected by the operation. The `int` value returned by the `executeUpdate()` method indicates the number of entities affected by the operation.
@ -582,7 +582,7 @@ include::{extrasdir}/statement_delete_bnf.txt[]
---- ----
==== ====
A `DELETE` statement is also executed using the `executeUpdate()` method of either `org.hibernate.query.Query` or `javax.persistence.Query`. A `DELETE` statement is also executed using the `executeUpdate()` method of either `org.hibernate.query.Query` or `jakarta.persistence.Query`.
[[hql-insert]] [[hql-insert]]
=== Insert statements === Insert statements
@ -975,7 +975,7 @@ VALUE::
Useful to explicitly show intent. Useful to explicitly show intent.
Valid for any type of collection-valued reference. Valid for any type of collection-valued reference.
INDEX:: INDEX::
According to HQL rules, this is valid for both `Maps` and `Lists` which specify a `javax.persistence.OrderColumn` annotation to refer to the `Map` key or the `List` position (aka the `OrderColumn` value). According to HQL rules, this is valid for both `Maps` and `Lists` which specify a `jakarta.persistence.OrderColumn` annotation to refer to the `Map` key or the `List` position (aka the `OrderColumn` value).
JPQL however, reserves this for use in the `List` case and adds `KEY` for the `Map` case. JPQL however, reserves this for use in the `List` case and adds `KEY` for the `Map` case.
Applications interested in JPA provider portability should be aware of this distinction. Applications interested in JPA provider portability should be aware of this distinction.
KEY:: KEY::

View File

@ -272,7 +272,7 @@ include::{sourcedir}/SQLTest.java[tags=sql-hibernate-multi-entity-query-alias-ex
[NOTE] [NOTE]
==== ====
There's no such equivalent in JPA because the `javax.persistence.Query` interface does not define an `addEntity` method equivalent. There's no such equivalent in JPA because the `jakarta.persistence.Query` interface does not define an `addEntity` method equivalent.
==== ====
The `{pr.*}` and `{pt.*}` notation used above is shorthand for "all properties". The `{pr.*}` and `{pt.*}` notation used above is shorthand for "all properties".
@ -337,7 +337,7 @@ include::{sourcedir}/SQLTest.java[tags=sql-hibernate-dto-query-example, indent=0
[NOTE] [NOTE]
==== ====
There's no such equivalent in JPA because the `javax.persistence.Query` interface does not define a `setResultTransformer` method equivalent. There's no such equivalent in JPA because the `jakarta.persistence.Query` interface does not define a `setResultTransformer` method equivalent.
==== ====
The above query will return a list of `PersonSummaryDTO` which has been instantiated and injected the values of `id` and `name` into its corresponding properties or fields. The above query will return a list of `PersonSummaryDTO` which has been instantiated and injected the values of `id` and `name` into its corresponding properties or fields.
@ -358,7 +358,7 @@ include::{sourcedir}/SQLTest.java[tags=sql-hibernate-inheritance-query-example]
[NOTE] [NOTE]
==== ====
There's no such equivalent in JPA because the `javax.persistence.Query` interface does not define an `addEntity` method equivalent. There's no such equivalent in JPA because the `jakarta.persistence.Query` interface does not define an `addEntity` method equivalent.
==== ====
[[sql-query-parameters]] [[sql-query-parameters]]
@ -390,7 +390,7 @@ include::{sourcedir}/SQLTest.java[tags=sql-hibernate-query-parameters-example]
Named SQL queries can also be defined during mapping and called in exactly the same way as a named HQL query. Named SQL queries can also be defined during mapping and called in exactly the same way as a named HQL query.
In this case, you do _not_ need to call `addEntity()` anymore. In this case, you do _not_ need to call `addEntity()` anymore.
JPA defines the `javax.persistence.NamedNativeQuery` annotation for this purpose, JPA defines the `jakarta.persistence.NamedNativeQuery` annotation for this purpose,
and the Hibernate `org.hibernate.annotations.NamedNativeQuery` annotation extends it and adds the following attributes: and the Hibernate `org.hibernate.annotations.NamedNativeQuery` annotation extends it and adds the following attributes:
`flushMode()`:: `flushMode()`::

View File

@ -7,12 +7,12 @@
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.Table; import jakarta.persistence.Table;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import javax.persistence.Entity; import jakarta.persistence.Entity;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import javax.persistence.Basic; import jakarta.persistence.Basic;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Lob; import jakarta.persistence.Lob;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -6,10 +6,10 @@
*/ */
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Version; import jakarta.persistence.Version;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -7,12 +7,12 @@
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Inheritance; import jakarta.persistence.Inheritance;
import javax.persistence.InheritanceType; import jakarta.persistence.InheritanceType;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -11,33 +11,33 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.ColumnResult; import jakarta.persistence.ColumnResult;
import javax.persistence.ConstructorResult; import jakarta.persistence.ConstructorResult;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.EntityResult; import jakarta.persistence.EntityResult;
import javax.persistence.EnumType; import jakarta.persistence.EnumType;
import javax.persistence.FieldResult; import jakarta.persistence.FieldResult;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.MapKeyEnumerated; import jakarta.persistence.MapKeyEnumerated;
import javax.persistence.NamedNativeQueries; import jakarta.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery; import jakarta.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries; import jakarta.persistence.NamedQueries;
import javax.persistence.NamedQuery; import jakarta.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQueries; import jakarta.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery; import jakarta.persistence.NamedStoredProcedureQuery;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import javax.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import javax.persistence.ParameterMode; import jakarta.persistence.ParameterMode;
import javax.persistence.QueryHint; import jakarta.persistence.QueryHint;
import javax.persistence.SqlResultSetMapping; import jakarta.persistence.SqlResultSetMapping;
import javax.persistence.SqlResultSetMappings; import jakarta.persistence.SqlResultSetMappings;
import javax.persistence.StoredProcedureParameter; import jakarta.persistence.StoredProcedureParameter;
import javax.persistence.Temporal; import jakarta.persistence.Temporal;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import javax.persistence.Version; import jakarta.persistence.Version;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -11,24 +11,24 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.ColumnResult; import jakarta.persistence.ColumnResult;
import javax.persistence.ConstructorResult; import jakarta.persistence.ConstructorResult;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.EntityResult; import jakarta.persistence.EntityResult;
import javax.persistence.EnumType; import jakarta.persistence.EnumType;
import javax.persistence.Enumerated; import jakarta.persistence.Enumerated;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.FieldResult; import jakarta.persistence.FieldResult;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.MapKey; import jakarta.persistence.MapKey;
import javax.persistence.MapKeyTemporal; import jakarta.persistence.MapKeyTemporal;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import javax.persistence.SqlResultSetMapping; import jakarta.persistence.SqlResultSetMapping;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.annotations.NamedNativeQueries; import org.hibernate.annotations.NamedNativeQueries;
import org.hibernate.annotations.NamedNativeQuery; import org.hibernate.annotations.NamedNativeQuery;

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.userguide.model; package org.hibernate.userguide.model;
import javax.persistence.Entity; import jakarta.persistence.Entity;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea

View File

@ -37,7 +37,7 @@ These interfaces are fully intended to be exposed to application code.
<p></p> <p></p>
<h3>JPA</h3> <h3>JPA</h3>
The JPA interfaces are all defined by the JPA specification. For details see {@link javax.persistence}. The JPA interfaces are all defined by the JPA specification. For details see {@link jakarta.persistence}.
Not that since 5.2 Hibernate extends JPA (e.g. SessionFactory extends EntityManagerFactory) rather Not that since 5.2 Hibernate extends JPA (e.g. SessionFactory extends EntityManagerFactory) rather
than wrapping it. than wrapping it.
<p></p> <p></p>

View File

@ -11,16 +11,16 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Embeddable; import jakarta.persistence.Embeddable;
import javax.persistence.EmbeddedId; import jakarta.persistence.EmbeddedId;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.MapsId; import jakarta.persistence.MapsId;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,11 +8,11 @@ package org.hibernate.userguide.associations;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.PrimaryKeyJoinColumn;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.MapsId; import jakarta.persistence.MapsId;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,12 +8,12 @@ package org.hibernate.userguide.associations;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.JoinColumnOrFormula; import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinFormula; import org.hibernate.annotations.JoinFormula;

View File

@ -7,10 +7,10 @@
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.JoinFormula; import org.hibernate.annotations.JoinFormula;
import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.dialect.PostgreSQLDialect;

View File

@ -9,12 +9,12 @@ package org.hibernate.userguide.associations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -10,13 +10,13 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,12 +8,12 @@ package org.hibernate.userguide.associations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,13 +6,13 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.ForeignKey; import jakarta.persistence.ForeignKey;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -1,13 +1,13 @@
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;

View File

@ -9,13 +9,13 @@ package org.hibernate.userguide.associations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,12 +8,12 @@ package org.hibernate.userguide.associations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,14 +6,14 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.annotations.LazyToOne; import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.LazyToOneOption;

View File

@ -6,14 +6,14 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
@ -71,7 +71,7 @@ public class OneToOneBidirectionalTest extends BaseEntityManagerFunctionalTestCa
entityManager.flush(); entityManager.flush();
entityManager.clear(); entityManager.clear();
//throws javax.persistence.PersistenceException: org.hibernate.HibernateException: More than one row with the given identifier was found: 1 //throws jakarta.persistence.PersistenceException: org.hibernate.HibernateException: More than one row with the given identifier was found: 1
phone = entityManager.find( Phone.class, phone.getId() ); phone = entityManager.find( Phone.class, phone.getId() );
//end::associations-one-to-one-bidirectional-constraint-example[] //end::associations-one-to-one-bidirectional-constraint-example[]
phone.getDetails().getProvider(); phone.getDetails().getProvider();

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.MapsId; import jakarta.persistence.MapsId;
import javax.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.MapsId; import jakarta.persistence.MapsId;
import javax.persistence.OneToOne; import jakarta.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.PrimaryKeyJoinColumn;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,12 +6,12 @@
*/ */
package org.hibernate.userguide.associations; package org.hibernate.userguide.associations;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,12 +8,12 @@ package org.hibernate.userguide.associations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -6,10 +6,10 @@
*/ */
package org.hibernate.userguide.associations.any; package org.hibernate.userguide.associations.any;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
//tag::associations-any-property-example[] //tag::associations-any-property-example[]

View File

@ -6,11 +6,11 @@
*/ */
package org.hibernate.userguide.associations.any; package org.hibernate.userguide.associations.any;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Any; import org.hibernate.annotations.Any;

View File

@ -8,12 +8,12 @@ package org.hibernate.userguide.associations.any;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.JoinTable; import jakarta.persistence.JoinTable;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Cascade; import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.ManyToAny; import org.hibernate.annotations.ManyToAny;

View File

@ -6,10 +6,10 @@
*/ */
package org.hibernate.userguide.associations.any; package org.hibernate.userguide.associations.any;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
//tag::associations-any-property-example[] //tag::associations-any-property-example[]

View File

@ -6,8 +6,8 @@
*/ */
package org.hibernate.userguide.batch; package org.hibernate.userguide.batch;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityTransaction; import jakarta.persistence.EntityTransaction;
import org.hibernate.CacheMode; import org.hibernate.CacheMode;
import org.hibernate.ScrollMode; import org.hibernate.ScrollMode;

View File

@ -14,20 +14,20 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import javax.persistence.AttributeConverter; import jakarta.persistence.AttributeConverter;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.EntityManager; import jakarta.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Persistence; import jakarta.persistence.Persistence;
import javax.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
import javax.persistence.PersistenceProperty; import jakarta.persistence.PersistenceProperty;
import javax.persistence.PersistenceUnit; import jakarta.persistence.PersistenceUnit;
import javax.persistence.SharedCacheMode; import jakarta.persistence.SharedCacheMode;
import javax.persistence.ValidationMode; import jakarta.persistence.ValidationMode;
import javax.persistence.spi.ClassTransformer; import jakarta.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo; import jakarta.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.PersistenceUnitTransactionType; import jakarta.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.hibernate.EmptyInterceptor; import org.hibernate.EmptyInterceptor;
@ -336,7 +336,7 @@ public class BootstrapTest {
} }
//tag::bootstrap-event-listener-registration-example[] //tag::bootstrap-event-listener-registration-example[]
public class MyIntegrator implements org.hibernate.integrator.spi.Integrator { public class MyIntegrator implements Integrator {
@Override @Override
public void integrate( public void integrate(

View File

@ -8,18 +8,17 @@ package org.hibernate.userguide.caching;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -30,16 +29,7 @@ public class FirstLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
@Override @Override
protected Class<?>[] getAnnotatedClasses() { protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { return new Class<?>[] { Person.class };
Person.class
};
}
@Override
@SuppressWarnings( "unchecked" )
protected void addConfigOptions(Map options) {
options.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, Boolean.TRUE.toString() );
options.put( AvailableSettings.CACHE_REGION_FACTORY, "jcache" );
} }
@Test @Test

View File

@ -9,25 +9,23 @@ package org.hibernate.userguide.caching;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.cache.configuration.MutableConfiguration;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Version;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.cache.jcache.JCacheHelper;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpected;
import org.junit.Test; import org.junit.Test;
import org.jboss.logging.Logger; import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Version;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -35,22 +33,23 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
/** /**
* @author Vlad Mihalcea * @author Vlad Mihalcea
*/ */
@FailureExpected( jiraKey = "", message = "Relies on hibernate-jcache + JCache + Ehcache - Ehcache uses JAXB and has not been updated to use Jakarta" )
public class NonStrictReadWriteCacheTest extends BaseEntityManagerFunctionalTestCase { public class NonStrictReadWriteCacheTest extends BaseEntityManagerFunctionalTestCase {
@Override @Override
public void buildEntityManagerFactory() { public void buildEntityManagerFactory() {
JCacheHelper.locateStandardCacheManager().createCache( // JCacheHelper.locateStandardCacheManager().createCache(
"hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Person", // "hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Person",
new MutableConfiguration<>() // new MutableConfiguration<>()
); // );
JCacheHelper.locateStandardCacheManager().createCache( // JCacheHelper.locateStandardCacheManager().createCache(
"hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Phone", // "hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Phone",
new MutableConfiguration<>() // new MutableConfiguration<>()
); // );
JCacheHelper.locateStandardCacheManager().createCache( // JCacheHelper.locateStandardCacheManager().createCache(
"hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Person.phones", // "hibernate.test.org.hibernate.userguide.caching.NonStrictReadWriteCacheTest$Person.phones",
new MutableConfiguration<>() // new MutableConfiguration<>()
); // );
super.buildEntityManagerFactory(); super.buildEntityManagerFactory();
} }

View File

@ -9,14 +9,14 @@ package org.hibernate.userguide.caching;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.persistence.CacheRetrieveMode; import jakarta.persistence.CacheRetrieveMode;
import javax.persistence.CacheStoreMode; import jakarta.persistence.CacheStoreMode;
import javax.persistence.Cacheable; import jakarta.persistence.Cacheable;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.CacheMode; import org.hibernate.CacheMode;
import org.hibernate.Session; import org.hibernate.Session;
@ -162,7 +162,7 @@ public class SecondLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
.setParameter( "id", 0L) .setParameter( "id", 0L)
.setHint( QueryHints.HINT_CACHEABLE, "true") .setHint( QueryHints.HINT_CACHEABLE, "true")
.setHint( QueryHints.HINT_CACHE_REGION, "query.cache.person" ) .setHint( QueryHints.HINT_CACHE_REGION, "query.cache.person" )
.setHint( "javax.persistence.cache.storeMode", CacheStoreMode.REFRESH ) .setHint( "jakarta.persistence.cache.storeMode", CacheStoreMode.REFRESH )
.getResultList(); .getResultList();
//end::caching-query-region-store-mode-jpa-example[] //end::caching-query-region-store-mode-jpa-example[]
}); });
@ -206,8 +206,8 @@ public class SecondLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
doInJPA( this::entityManagerFactory, entityManager -> { doInJPA( this::entityManagerFactory, entityManager -> {
//tag::caching-management-cache-mode-entity-jpa-example[] //tag::caching-management-cache-mode-entity-jpa-example[]
Map<String, Object> hints = new HashMap<>( ); Map<String, Object> hints = new HashMap<>( );
hints.put( "javax.persistence.cache.retrieveMode" , CacheRetrieveMode.USE ); hints.put( "jakarta.persistence.cache.retrieveMode" , CacheRetrieveMode.USE );
hints.put( "javax.persistence.cache.storeMode" , CacheStoreMode.REFRESH ); hints.put( "jakarta.persistence.cache.storeMode" , CacheStoreMode.REFRESH );
Person person = entityManager.find( Person.class, 1L , hints); Person person = entityManager.find( Person.class, 1L , hints);
//end::caching-management-cache-mode-entity-jpa-example[] //end::caching-management-cache-mode-entity-jpa-example[]
}); });
@ -225,8 +225,8 @@ public class SecondLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
List<Person> persons = entityManager.createQuery( List<Person> persons = entityManager.createQuery(
"select p from Person p", Person.class) "select p from Person p", Person.class)
.setHint( QueryHints.HINT_CACHEABLE, "true") .setHint( QueryHints.HINT_CACHEABLE, "true")
.setHint( "javax.persistence.cache.retrieveMode" , CacheRetrieveMode.USE ) .setHint( "jakarta.persistence.cache.retrieveMode" , CacheRetrieveMode.USE )
.setHint( "javax.persistence.cache.storeMode" , CacheStoreMode.REFRESH ) .setHint( "jakarta.persistence.cache.storeMode" , CacheStoreMode.REFRESH )
.getResultList(); .getResultList();
//end::caching-management-cache-mode-query-jpa-example[] //end::caching-management-cache-mode-query-jpa-example[]

View File

@ -6,8 +6,8 @@
*/ */
package org.hibernate.userguide.collections; package org.hibernate.userguide.collections;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,8 +8,8 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;

View File

@ -8,9 +8,9 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,10 +8,10 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,12 +9,12 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,12 +9,12 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -11,12 +11,12 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortComparator;

View File

@ -11,15 +11,15 @@ import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.MapKey; import jakarta.persistence.MapKey;
import javax.persistence.MapKeyEnumerated; import jakarta.persistence.MapKeyEnumerated;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,13 +9,13 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import javax.persistence.OrderBy; import jakarta.persistence.OrderBy;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,13 +9,13 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import javax.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,12 +9,12 @@ package org.hibernate.userguide.collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -10,12 +10,12 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.SortNatural;

View File

@ -9,15 +9,15 @@ package org.hibernate.userguide.collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.CollectionTable; import jakarta.persistence.CollectionTable;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Embeddable; import jakarta.persistence.Embeddable;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.MapKeyJoinColumn; import jakarta.persistence.MapKeyJoinColumn;
import javax.persistence.Temporal; import jakarta.persistence.Temporal;
import javax.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -8,11 +8,11 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Embeddable; import jakarta.persistence.Embeddable;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -9,16 +9,16 @@ package org.hibernate.userguide.collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CollectionTable; import jakarta.persistence.CollectionTable;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Embeddable; import jakarta.persistence.Embeddable;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.MapKeyClass; import jakarta.persistence.MapKeyClass;
import javax.persistence.MapKeyColumn; import jakarta.persistence.MapKeyColumn;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -12,15 +12,15 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.CollectionTable; import jakarta.persistence.CollectionTable;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import javax.persistence.MapKeyColumn; import jakarta.persistence.MapKeyColumn;
import javax.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.MapKeyType; import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;

View File

@ -9,13 +9,13 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import javax.persistence.OrderColumn; import jakarta.persistence.OrderColumn;
import org.hibernate.annotations.ListIndexBase; import org.hibernate.annotations.ListIndexBase;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;

View File

@ -8,13 +8,13 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.FetchType; import jakarta.persistence.FetchType;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -10,11 +10,11 @@ import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Objects; import java.util.Objects;
import java.util.Queue; import java.util.Queue;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.CollectionType; import org.hibernate.annotations.CollectionType;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;

View File

@ -8,11 +8,11 @@ package org.hibernate.userguide.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;

View File

@ -11,11 +11,11 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import javax.persistence.CascadeType; import jakarta.persistence.CascadeType;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortComparator;

Some files were not shown because too many files have changed in this diff Show More