HHH-18453 - Fix Java code block highlighting in User Guide

This commit is contained in:
Steve Ebersole 2024-07-31 08:01:19 -05:00
parent 257adaf633
commit 903f577129
29 changed files with 676 additions and 677 deletions

View File

@ -3,5 +3,4 @@
- [[[PoEAA]]] Martin Fowler. https://www.martinfowler.com/books/eaa.html[Patterns of Enterprise Application Architecture].
Addison-Wesley Professional. 2002.
- [[[JPwH]]] Christian Bauer & Gavin King. https://www.manning.com/books/java-persistence-with-hibernate-second-edition[Java Persistence with Hibernate, Second Edition]. Manning Publications Co. 2015.
- [[[jdbc]]] https://download.oracle.com/otndocs/jcp/jdbc-4_2-mrel2-spec/[JDBC Specification - Version 4.2]
- [[[jdbc]]] https://download.oracle.com/otndocs/jcp/jdbc-4_3-mrel3-spec/[JDBC Specification - Version 4.3]

View File

@ -46,7 +46,7 @@ Since version 5.2, Hibernate allows overriding the global JDBC batch size given
[[batch-session-jdbc-batch-size-example]]
.Hibernate specific JDBC batch size configuration on a per `Session` basis
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-jdbc-batch-size-example]
----
@ -60,7 +60,7 @@ The following example shows an anti-pattern for batch inserts.
[[batch-session-batch-example]]
.Naive way to insert 100 000 entities with Hibernate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-batch-example]
----
@ -88,7 +88,7 @@ When you make new objects persistent, employ methods `flush()` and `clear()` to
[[batch-session-batch-insert-example]]
.Flushing and clearing the `Session`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-batch-insert-example]
----
@ -103,7 +103,7 @@ In addition, use method `scroll()` to take advantage of server-side cursors for
[[batch-session-scroll-example]]
.Using `scroll()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-scroll-example]
----
@ -149,7 +149,7 @@ IMPORTANT: Due to the lack of a first-level cache, stateless sessions are vulner
[[batch-stateless-session-example]]
.Using a `StatelessSession`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-stateless-session-example]
----
@ -205,7 +205,7 @@ You can use sub-queries in the `WHERE` clause, and the sub-queries themselves ca
[[batch-bulk-jpql-update-example]]
.Executing a JPQL `UPDATE`, using the `Query.executeUpdate()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-update-example]
----
@ -214,7 +214,7 @@ include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-update-exa
[[batch-bulk-hql-update-example]]
.Executing an HQL `UPDATE`, using the `Query.executeUpdate()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-update-example]
----
@ -226,7 +226,7 @@ You can use a versioned update to force Hibernate to reset the version or timest
[[batch-bulk-hql-update-version-example]]
.Updating the version of timestamp
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-update-version-example]
----
@ -242,7 +242,7 @@ This feature is only available in HQL since it's not standardized by Jakarta Per
[[batch-bulk-jpql-delete-example]]
.A JPQL `DELETE` statement
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-delete-example]
----
@ -251,7 +251,7 @@ include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-delete-exa
[[batch-bulk-hql-delete-example]]
.An HQL `DELETE` statement
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-delete-example]
----
@ -309,7 +309,7 @@ in which case the seed value defined by the `org.hibernate.type.descriptor.java.
[[batch-bulk-hql-insert-example]]
.HQL INSERT statement
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-insert-example]
----
@ -344,7 +344,7 @@ The `Person` entity is the base class of this entity inheritance model, and is m
[[batch-bulk-hql-temp-table-base-class-example]]
.Bulk mutation base class entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-bulkid}/AbstractMutationStrategyCompositeIdTest.java[tags=batch-bulk-hql-temp-table-base-class-example]
----
@ -355,7 +355,7 @@ Both the `Doctor` and `Engineer` entity classes extend the `Person` base class:
[[batch-bulk-hql-temp-table-sub-classes-example]]
.Bulk mutation subclass entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-bulkid}/AbstractMutationStrategyIdTest.java[tags=batch-bulk-hql-temp-table-sub-classes-example]
----
@ -369,7 +369,7 @@ Now, when you try to execute a bulk entity delete query:
[[batch-bulk-hql-temp-table-delete-query-example]]
.Bulk mutation delete query example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-bulkid}/AbstractMutationStrategyCompositeIdTest.java[tags=batch-bulk-hql-temp-table-delete-query-example]
----

View File

@ -68,7 +68,7 @@ We can inject the `EntityManagerFactory` -
[[bootstrap-jpa-compliant-PersistenceUnit-configurable-example]]
.Injecting a specific `EntityManagerFactory`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=bootstrap-jpa-compliant-PersistenceUnit-configurable-example]
----
@ -79,7 +79,7 @@ Because there is only one `<persistence-unit/>` defined, we can also omit the na
[[bootstrap-jpa-compliant-PersistenceUnit-example]]
.Injecting the default `EntityManagerFactory`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=bootstrap-jpa-compliant-PersistenceUnit-example]
----
@ -104,7 +104,7 @@ and either -
[[example-bootstrap-jpa-compliant-EntityManagerFactory]]
.Application bootstrapped `EntityManagerFactory`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=bootstrap-jpa-compliant-EntityManagerFactory-example]
----
@ -118,7 +118,7 @@ Jakarta Persistence 3.2 also introduced a new way for applications to build the
[[example-bootstrap-standard-PersistenceConfiguration]]
.Using PersistenceConfiguration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot-jpa}/PersistenceConfigurationTests.java[tags=example-bootstrap-standard-PersistenceConfiguration]
----
@ -130,7 +130,7 @@ which exposes additional conveniences.
[[example-bootstrap-standard-HibernatePersistenceConfiguration]]
.Using HibernatePersistenceConfiguration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot-jpa}/PersistenceConfigurationTests.java[tags=example-bootstrap-standard-HibernatePersistenceConfiguration]
----
@ -254,7 +254,7 @@ If you wish to alter how the `BootstrapServiceRegistry` is built, that is contro
[[example-bootstrap-native-BootstrapServiceRegistry]]
.Controlling `BootstrapServiceRegistry` building
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-BootstrapServiceRegistry]
----
@ -266,7 +266,7 @@ You will almost always need to configure this registry, which is done through `o
[[example-bootstrap-native-StandardServiceRegistryBuilder]]
.Building a `BootstrapServiceRegistryBuilder`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-StandardServiceRegistryBuilder]
----
@ -289,7 +289,7 @@ This mapping information might be in the form of XML, annotations or both.
[[example-bootstrap-native-MetadataSources]]
.Building a `MetadataSources`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-MetadataSources]
----
@ -300,7 +300,7 @@ Also, all methods on `MetadataSources` offer fluent-style call chaining -
[[bootstrap-native-metadata-source-example]]
.Configuring a `MetadataSources` with method chaining
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-MetadataSources-chained]
----
@ -315,7 +315,7 @@ If you have specified everything as settings, or you are ok with the default beh
[[example-bootstrap-native-Metadata-no-builder]]
.Using `MetadataSources#buildMetadata`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-Metadata-no-builder]
----
@ -327,7 +327,7 @@ Optionally, we can obtain a `MetadataBuilder` from `MetadataSources` which can b
[[example-bootstrap-native-MetadataBuilder]]
.Using `MetadataBuilder`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-Metadata-using-builder]
----
@ -355,7 +355,7 @@ link:{doc-javadoc-url}/org/hibernate/boot/Metadata.html#buildSessionFactory--[`M
[[example-bootstrap-native-SessionFactory-no-builder]]
.Using `SessionFactoryBuilder`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-SessionFactory-no-builder]
----
@ -366,7 +366,7 @@ Or a `SessionFactoryBuilder`, obtained from `Metadata`, may be used to configure
[[example-bootstrap-native-SessionFactoryBuilder]]
.Using `SessionFactoryBuilder`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=example-bootstrap-native-SessionFactory-using-builder]
----
@ -380,7 +380,7 @@ A common use case for `Integrator`, for example, is to hook in custom event list
[[example-bootstrap-event-listener-registration]]
.Configuring an event listener
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-boot}/BootstrapTest.java[tags=bootstrap-event-listener-registration-example]
----

View File

@ -167,7 +167,7 @@ Nevertheless, the reasons why we advise you to have all entities belonging to an
[[caching-entity-mapping-example]]
.Entity cache mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/NonStrictReadWriteCacheTest.java[tags=caching-entity-mapping-example]
----
@ -182,7 +182,7 @@ Once an entity is stored in the second-level cache, you can avoid a database hit
[[caching-entity-jpa-example]]
.Loading entity using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-jpa-example]
----
@ -191,7 +191,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-jpa
[[caching-entity-native-example]]
.Loading entity using Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-native-example]
----
@ -202,7 +202,7 @@ The Hibernate second-level cache can also load entities by their <<chapters/doma
[[caching-entity-natural-id-mapping-example]]
.Hibernate natural id entity mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-natural-id-mapping-example]
----
@ -211,7 +211,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-nat
[[caching-entity-natural-id-example]]
.Loading entity using Hibernate native natural id API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-entity-natural-id-example]
----
@ -230,7 +230,7 @@ the collection cache entry will store the entity identifiers only.
[[caching-collection-mapping-example]]
.Collection cache mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/NonStrictReadWriteCacheTest.java[tags=caching-collection-mapping-example]
----
@ -241,7 +241,7 @@ Collections are read-through, meaning they are cached upon being accessed for th
[[caching-collection-example]]
.Collection cache usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/NonStrictReadWriteCacheTest.java[tags=caching-collection-example]
----
@ -292,7 +292,7 @@ This way, the query looks for existing cache results or adds the query results t
[[caching-query-jpa-example]]
.Caching query using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-jpa-example]
----
@ -301,7 +301,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-jpa-
[[caching-query-native-example]]
.Caching query using Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-native-example]
----
@ -339,7 +339,7 @@ you can specify a named cache region for a particular query.
[[caching-query-region-jpa-example]]
.Caching query in custom region using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-region-jpa-example]
----
@ -348,7 +348,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-regi
[[caching-query-region-native-example]]
.Caching query in custom region using Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-region-native-example]
----
@ -360,7 +360,7 @@ you can use custom cache modes.
[[caching-query-region-store-mode-jpa-example]]
.Using custom query cache mode with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-region-store-mode-jpa-example]
----
@ -369,7 +369,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-regi
[[caching-query-region-store-mode-native-example]]
.Using custom query cache mode with Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-region-store-mode-native-example]
----
@ -383,7 +383,7 @@ Hibernate will selectively force the results cached in that particular region to
This behavior is particularly useful in cases when the underlying data may have been updated via a separate process
and is a far more efficient alternative to the bulk eviction of the region via `SessionFactory` eviction which looks as follows:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-query-region-native-evict-example]
----
@ -442,7 +442,7 @@ Setting the cache mode can be done either when loading entities directly or when
[[caching-management-cache-mode-entity-jpa-example]]
.Using custom cache modes with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-cache-mode-entity-jpa-example]
----
@ -451,7 +451,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management
[[caching-management-cache-mode-entity-native-example]]
.Using custom cache modes with Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-cache-mode-entity-native-example]
----
@ -462,7 +462,7 @@ The custom cache modes can be set for queries as well:
[[caching-management-cache-mode-query-jpa-example]]
.Using custom cache modes for queries with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-cache-mode-query-jpa-example]
----
@ -471,7 +471,7 @@ include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management
[[caching-management-cache-mode-query-native-example]]
.Using custom cache modes for queries with Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-cache-mode-query-native-example]
----
@ -488,7 +488,7 @@ Jakarta Persistence only supports entity eviction through the {jpaJavadocUrlPref
[[caching-management-evict-jpa-example]]
.Evicting entities with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-evict-jpa-example]
----
@ -505,7 +505,7 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern
[[caching-management-evict-native-example]]
.Evicting entities with Hibernate native API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-management-evict-native-example]
----
@ -524,7 +524,7 @@ second-level cache metrics.
[[caching-statistics-example]]
.Caching statistics
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/SecondLevelCacheTest.java[tags=caching-statistics-example]
----

View File

@ -615,7 +615,7 @@ For this example, consider the following `Property` class hierarchy:
[[associations-any-property-example]]
.`Property` class hierarchy
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/Property.java[tags=associations-any-property-example]
@ -630,7 +630,7 @@ A `PropertyHolder` entity defines an attribute of type `Property`:
[[associations-any-example]]
.`@Any` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/PropertyHolder.java[tags=associations-any-example]
----
@ -657,7 +657,7 @@ Hibernate will generate the following SQL queries:
[[associations-any-persist-example]]
.`@Any` mapping persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/AnyTest.java[tags=associations-any-persist-example]
----
@ -674,7 +674,7 @@ Hibernate will fetch the associated `StringProperty` entity like this:
[[associations-any-query-example]]
.`@Any` mapping query example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/AnyTest.java[tags=associations-any-query-example]
----
@ -700,7 +700,7 @@ into a single annotation that we can apply in each usage.
[[associations-any-composed-example]]
.`@Any` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/PropertyHolder2.java[tags=associations-any-def-example]
----
@ -731,7 +731,7 @@ The `repository_properties` link table holds the associations between `PropertyR
[[associations-many-to-any-example]]
.`@ManyToAny` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/PropertyRepository.java[tags=associations-many-to-any-example]
----
@ -751,7 +751,7 @@ Hibernate will generate the following SQL queries:
[[associations-many-to-any-persist-example]]
.`@ManyToAny` mapping persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/ManyToAnyTest.java[tags=associations-many-to-any-persist-example]
----
@ -768,7 +768,7 @@ Hibernate will fetch the associated `IntegerProperty` and `StringProperty` entit
[[associations-many-to-any-query-example]]
.`@ManyToAny` mapping query example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/any/ManyToAnyTest.java[tags=associations-many-to-any-query-example]
----
@ -789,7 +789,7 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern
[[associations-JoinFormula-example]]
.`@JoinFormula` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinFormulaTest.java[tags=associations-JoinFormula-example]
----
@ -807,7 +807,7 @@ Considering we have the following entities:
[[associations-JoinFormula-persistence-example]]
.`@JoinFormula` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinFormulaTest.java[tags=associations-JoinFormula-persistence-example]
----
@ -818,7 +818,7 @@ When fetching the `User` entities, the `country` property is mapped by the `@Joi
[[associations-JoinFormula-fetching-example]]
.`@JoinFormula` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinFormulaTest.java[tags=associations-JoinFormula-fetching-example]
----
@ -839,7 +839,7 @@ The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibern
[[associations-JoinColumnOrFormula-example]]
.`@JoinColumnOrFormula` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinColumnOrFormulaTest.java[tags=associations-JoinColumnOrFormula-example]
----
@ -857,7 +857,7 @@ Considering we have the following entities:
[[associations-JoinColumnOrFormula-persistence-example]]
.`@JoinColumnOrFormula` persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinColumnOrFormulaTest.java[tags=associations-JoinColumnOrFormula-persistence-example]
----
@ -868,7 +868,7 @@ When fetching the `User` entities, the `country` property is mapped by the `@Joi
[[associations-JoinColumnOrFormula-fetching-example]]
.`@JoinColumnOrFormula` fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-association}/JoinColumnOrFormulaTest.java[tags=associations-JoinColumnOrFormula-fetching-example]
----

View File

@ -60,7 +60,7 @@ examples are ultimately the same.
[[basic-annotation-explicit-example]]
.`@Basic` explicit
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ExplicitBasicTypeTest.java[tags=basic-annotation-explicit-example]
----
@ -69,7 +69,7 @@ include::{example-dir-basic-mapping}/basic/ExplicitBasicTypeTest.java[tags=basic
[[basic-annotation-implicit-example]]
.`@Basic` implied
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ImplicitBasicTypeTest.java[tags=basic-annotation-implicit-example]
----
@ -105,7 +105,7 @@ If that implicit naming rule does not meet your requirements, you can explicitly
[[basic-annotation-explicit-column-example]]
.Explicit column naming
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ExplicitColumnNamingTest.java[tags=basic-annotation-explicit-column-example]
----
@ -135,7 +135,7 @@ The `@Column` annotation defines other mapping information as well. See its Java
[[mapping-column-formula-example]]
.`@Formula` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/FormulaTest.java[tags=mapping-column-formula-example]
----
@ -146,7 +146,7 @@ When loading the `Account` entity, Hibernate is going to calculate the `interest
[[mapping-column-formula-persistence-example]]
.Persisting an entity with a `@Formula` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/FormulaTest.java[tags=mapping-column-formula-persistence-example]
----
@ -254,7 +254,7 @@ Assuming the following enumeration:
.`PhoneType` enumeration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/PhoneType.java[tags=hql-examples-domain-model-example]
----
@ -269,7 +269,7 @@ In the ORDINAL example, the `phone_type` column is defined as a (nullable) INTEG
[[basic-enums-Enumerated-ordinal-example]]
.`@Enumerated(ORDINAL)` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/PhoneTypeEnumeratedOrdinalTest.java[tags=basic-enums-Enumerated-ordinal-example]
----
@ -280,7 +280,7 @@ When persisting this entity, Hibernate generates the following SQL statement:
[[basic-enums-Enumerated-ordinal-persistence-example]]
.Persisting an entity with an `@Enumerated(ORDINAL)` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/PhoneTypeEnumeratedOrdinalTest.java[tags=basic-enums-Enumerated-ordinal-persistence-example]
----
@ -300,7 +300,7 @@ In the STRING example, the `phone_type` column is defined as a (nullable) VARCHA
[[basic-enums-Enumerated-string-example]]
.`@Enumerated(STRING)` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/PhoneTypeEnumeratedStringTest.java[tags=basic-enums-Enumerated-string-example]
----
@ -325,7 +325,7 @@ Let's consider the following `Gender` enum which stores its values using the `'M
[[basic-enums-converter-example]]
.Enum with a custom constructor
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/Gender.java[tags=basic-enums-converter-example]
----
@ -336,7 +336,7 @@ You can map enums in a Jakarta Persistence compliant way using a Jakarta Persist
[[basic-enums-attribute-converter-example]]
.Enum mapping with `AttributeConverter` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/EnumerationConverterTest.java[tags=basic-enums-attribute-converter-example]
----
@ -368,7 +368,7 @@ Let's again revisit the Gender enum example, this time using a custom Type to st
[[basic-enums-custom-type-example]]
.Enum mapping with custom Type example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/EnumerationCustomTypeTest.java[tags=basic-enums-custom-type-example, indent=0]
@ -399,7 +399,7 @@ dedicated `BOOLEAN` type. On databases which don't, Hibernate uses whatever else
[[basic-boolean-example-implicit]]
.Implicit boolean mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BooleanMappingTests.java[tags=basic-boolean-example-implicit]
----
@ -416,7 +416,7 @@ provides 3 built-in converters for the common boolean mapping cases:
[[basic-boolean-example-converted]]
.Using `AttributeConverter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BooleanMappingTests.java[tags=basic-boolean-example-explicit-yes-no]
@ -442,7 +442,7 @@ By default, Hibernate maps values of `Byte` / `byte` to the `TINYINT` JDBC type.
[[basic-byte-example]]
.Mapping Byte
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ByteMappingTests.java[tags=basic-byte-example-implicit]
----
@ -464,7 +464,7 @@ By default, Hibernate maps values of `Short` / `short` to the `SMALLINT` JDBC ty
[[basic-short-example]]
.Mapping Short
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ShortMappingTests.java[tags=basic-short-example-implicit]
----
@ -483,7 +483,7 @@ By default, Hibernate maps values of `Integer` / `int` to the `INTEGER` JDBC typ
[[basic-integer-example]]
.Mapping Integer
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/IntegerMappingTests.java[tags=basic-integer-example-implicit]
----
@ -501,7 +501,7 @@ By default, Hibernate maps values of `Long` / `long` to the `BIGINT` JDBC type.
[[basic-long-example]]
.Mapping Long
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/LongMappingTests.java[tags=basic-long-example-implicit]
----
@ -520,7 +520,7 @@ By default, Hibernate maps values of `BigInteger` to the `NUMERIC` JDBC type.
[[basic-bitinteger-example]]
.Mapping BigInteger
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BigIntegerMappingTests.java[tags=basic-biginteger-example-implicit]
----
@ -540,7 +540,7 @@ By default, Hibernate maps values of `Double` to the `DOUBLE`, `FLOAT`, `REAL` o
[[basic-double-example]]
.Mapping Double
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/DoubleMappingTests.java[tags=basic-double-example-implicit]
----
@ -565,7 +565,7 @@ By default, Hibernate maps values of `Float` to the `FLOAT`, `REAL` or
[[basic-float-example]]
.Mapping Float
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/FloatMappingTests.java[tags=basic-float-example-implicit]
----
@ -589,7 +589,7 @@ By default, Hibernate maps values of `BigDecimal` to the `NUMERIC` JDBC type.
[[basic-bigdecimal-example]]
.Mapping BigDecimal
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BigDecimalMappingTests.java[tags=basic-bigdecimal-example-implicit]
----
@ -607,7 +607,7 @@ By default, Hibernate maps `Character` to the `CHAR` JDBC type.
[[basic-character-example]]
.Mapping Character
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/CharacterMappingTests.java[tags=basic-character-example-implicit]
----
@ -625,7 +625,7 @@ By default, Hibernate maps `String` to the `VARCHAR` JDBC type.
[[basic-string-example]]
.Mapping String
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/StringMappingTests.java[tags=basic-string-example]
----
@ -636,7 +636,7 @@ or using the `@Size` annotation from Hibernate Validator.
For very large strings, you can use one of the constant values defined by the class
`org.hibernate.Length`, for example:
[source, JAVA, indent=0]
[source, java, indent=0]
----
@Column(length=Length.LONG)
private String text;
@ -646,7 +646,7 @@ Alternatively, you may explicitly specify the JDBC type `LONGVARCHAR`, which is
as a `VARCHAR` mapping with default `length=Length.LONG` when no `length` is explicitly
specified:
[source, JAVA, indent=0]
[source, java, indent=0]
----
@JdbcTypeCode(Types.LONGVARCHAR)
private String text;
@ -672,7 +672,7 @@ nationalized data.
[[basic-nstring-example]]
.Mapping String as nationalized
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/StringNationalizedMappingTests.java[tags=basic-nstring-example]
----
@ -697,7 +697,7 @@ it is necessary to annotate the persistent attribute with `@JavaType( CharacterA
[[basic-string-example-implicit]]
.Mapping Character
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/CharacterArrayMappingTests.java[tags=basic-chararray-example]
----
@ -711,7 +711,7 @@ nationalized data.
[[basic-nchararray-example]]
.Mapping character arrays as nationalized
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/CharacterArrayNationalizedMappingTests.java[tags=basic-nchararray-example]
----
@ -750,7 +750,7 @@ Let's first map this using the `@Lob` Jakarta Persistence annotation and the `ja
[[basic-clob-example]]
.`CLOB` mapped to `java.sql.Clob`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClobTest.java[tags=basic-clob-example]
----
@ -761,7 +761,7 @@ To persist such an entity, you have to create a `Clob` using the `ClobProxy` Hib
[[basic-clob-persist-example]]
.Persisting a `java.sql.Clob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClobTest.java[tags=basic-clob-persist-example]
----
@ -772,7 +772,7 @@ To retrieve the `Clob` content, you need to transform the underlying `java.io.Re
[[basic-clob-find-example]]
.Returning a `java.sql.Clob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClobTest.java[tags=basic-clob-find-example]
----
@ -783,7 +783,7 @@ We could also map the CLOB in a materialized form. This way, we can either use a
[[basic-clob-string-example]]
.`CLOB` mapped to `String`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClobStringTest.java[tags=basic-clob-string-example]
----
@ -794,7 +794,7 @@ We might even want the materialized data as a char array.
[[basic-clob-char-array-example]]
.CLOB - materialized `char[]` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClobCharArrayTest.java[tags=basic-clob-char-array-example]
----
@ -805,7 +805,7 @@ Just like with `CLOB`, Hibernate can also deal with `NCLOB` SQL data types:
[[basic-nclob-sql-example]]
.`NCLOB` - SQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{extrasdir}/basic/basic-nclob-sql-example.sql[]
----
@ -816,7 +816,7 @@ Hibernate can map the `NCLOB` to a `java.sql.NClob`
[[basic-nclob-example]]
.`NCLOB` mapped to `java.sql.NClob`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NClobTest.java[tags=basic-nclob-example]
----
@ -827,7 +827,7 @@ To persist such an entity, you have to create an `NClob` using the `NClobProxy`
[[basic-nclob-persist-example]]
.Persisting a `java.sql.NClob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NClobTest.java[tags=basic-nclob-persist-example]
----
@ -838,7 +838,7 @@ To retrieve the `NClob` content, you need to transform the underlying `java.io.R
[[basic-nclob-find-example]]
.Returning a `java.sql.NClob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NClobTest.java[tags=basic-nclob-find-example]
----
@ -849,7 +849,7 @@ We could also map the `NCLOB` in a materialized form. This way, we can either us
[[basic-nclob-string-example]]
.`NCLOB` mapped to `String`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NClobStringTest.java[tags=basic-nclob-string-example]
----
@ -860,7 +860,7 @@ We might even want the materialized data as a char array.
[[basic-nclob-char-array-example]]
.NCLOB - materialized `char[]` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NClobCharArrayTest.java[tags=basic-nclob-char-array-example]
----
@ -884,7 +884,7 @@ it is necessary to annotate the persistent attribute with `@JavaType( ByteArrayJ
[[basic-bytearray-example]]
.Mapping arrays of bytes
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ByteArrayMappingTests.java[tags=basic-bytearray-example]
----
@ -942,7 +942,7 @@ Let's first map this using the JDBC `java.sql.Blob` type.
[[basic-blob-example]]
.`BLOB` mapped to `java.sql.Blob`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BlobTest.java[tags=basic-blob-example]
----
@ -953,7 +953,7 @@ To persist such an entity, you have to create a `Blob` using the `BlobProxy` Hib
[[basic-blob-persist-example]]
.Persisting a `java.sql.Blob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BlobTest.java[tags=basic-blob-persist-example]
----
@ -964,7 +964,7 @@ To retrieve the `Blob` content, you need to transform the underlying `java.io.In
[[basic-blob-find-example]]
.Returning a `java.sql.Blob` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BlobTest.java[tags=basic-blob-find-example]
----
@ -975,7 +975,7 @@ We could also map the BLOB in a materialized form (e.g. `byte[]`).
[[basic-blob-byte-array-example]]
.`BLOB` mapped to `byte[]`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BlobByteArrayTest.java[tags=basic-blob-byte-array-example]
----
@ -995,7 +995,7 @@ TIP: It's possible to map `Duration` to the `INTERVAL_SECOND` SQL type using `@J
[[basic-duration-example]]
.Mapping Duration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/DurationMappingTests.java[tags=basic-duration-example]
----
@ -1013,7 +1013,7 @@ include::{example-dir-basic-mapping}/basic/DurationMappingTests.java[tags=basic-
[[basic-instant-example]]
.Mapping Instant
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/InstantMappingTests.java[tags=basic-instant-example]
----
@ -1034,7 +1034,7 @@ See <<basic-temporal>> for basics of temporal mapping
[[basic-localDate-example]]
.Mapping LocalDate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/LocalDateMappingTests.java[tags=basic-localDate-example]
----
@ -1055,7 +1055,7 @@ See <<basic-temporal>> for basics of temporal mapping
[[basic-localDateTime-example]]
.Mapping LocalDateTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/LocalDateTimeMappingTests.java[tags=basic-localDateTime-example]
----
@ -1076,7 +1076,7 @@ See <<basic-temporal>> for basics of temporal mapping
[[basic-localTime-example]]
.Mapping LocalTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/LocalTimeMappingTests.java[tags=basic-localTime-example]
----
@ -1099,7 +1099,7 @@ depending on the database.
[[basic-OffsetDateTime-example]]
.Mapping OffsetDateTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/OffsetDateTimeMappingTests.java[tags=basic-OffsetDateTime-example]
----
@ -1125,7 +1125,7 @@ depending on the database.
[[basic-OffsetTime-example]]
.Mapping OffsetTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/OffsetTimeMappingTests.java[tags=basic-offsetTime-example]
----
@ -1147,7 +1147,7 @@ See <<basic-datetime-time-zone>> for basics of time-zone handling
[[basic-TimeZone-example]]
.Mapping OffsetTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/TimeZoneMappingTests.java[tags=basic-timeZone-example]
----
@ -1169,7 +1169,7 @@ depending on the database.
[[basic-ZonedDateTime-example]]
.Mapping ZonedDateTime
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ZonedDateTimeMappingTests.java[tags=basic-ZonedDateTime-example]
----
@ -1193,7 +1193,7 @@ See <<basic-datetime-time-zone>> for basics of time-zone handling
[[basic-ZoneOffset-example]]
.Mapping ZoneOffset
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ZoneOffsetMappingTests.java[tags=basic-ZoneOffset-example]
----
@ -1263,7 +1263,7 @@ Hibernate maps `Class` references to `VARCHAR` JDBC type
[[basic-Class-example]]
.Mapping Class
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ClassMappingTests.java[tags=basic-Class-example]
----
@ -1278,7 +1278,7 @@ Hibernate maps `Currency` references to `VARCHAR` JDBC type
[[basic-Currency-example]]
.Mapping Currency
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/CurrencyMappingTests.java[tags=basic-Currency-example]
----
@ -1293,7 +1293,7 @@ Hibernate maps `Locale` references to `VARCHAR` JDBC type
[[basic-Locale-example]]
.Mapping Locale
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/LocaleMappingTests.java[tags=basic-Locale-example]
----
@ -1344,7 +1344,7 @@ By default, Hibernate will map `InetAddress` to the `INET` SQL type and fallback
[[basic-inet-address-example]]
.Mapping InetAddress
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/InetAddressMappingTests.java[tags=basic-inet-address-example]
----
@ -1361,7 +1361,7 @@ as can be read in the <<appendices/Configurations.adoc#misc-options,Configuratio
[[basic-json-example]]
.Mapping JSON
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/JsonMappingTests.java[tags=basic-json-example]
----
@ -1378,7 +1378,7 @@ as can be read in the <<appendices/Configurations.adoc#misc-options,Configuratio
[[basic-xml-example]]
.Mapping XML
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/XmlMappingTests.java[tags=basic-xml-example]
----
@ -1396,7 +1396,7 @@ depending on the database support as determined via the new method `org.hibernat
[[basic-array-example]]
.Mapping basic arrays
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BasicArrayMappingTests.java[tags=basic-array-example]
----
@ -1414,7 +1414,7 @@ depending on the database support as determined via the new method `org.hibernat
[[basic-collection-example]]
.Mapping basic collections
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/BasicCollectionMappingTests.java[tags=basic-collection-example]
----
@ -1656,7 +1656,7 @@ Considering we have the following database table:
[[basic-nationalized-sql-example]]
.`NVARCHAR` - SQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{extrasdir}/basic/basic-nationalized-sql-example.sql[]
----
@ -1667,7 +1667,7 @@ To map a specific attribute to a nationalized variant data type, Hibernate defin
[[basic-nationalized-example]]
.`NVARCHAR` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/NationalizedTest.java[tags=basic-nationalized-example]
----
@ -1778,7 +1778,7 @@ use `@Temporal`.
[[basic-temporal-java-util-example]]
.Mapping java.util.Date
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/DatePrecisionTests.java[tags=basic-temporal-example]
----
@ -1879,7 +1879,7 @@ Due to this, storing the offset is only safe for past timestamps, and we advise
.`@TimeZoneColumn` usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/TimeZoneStorageMappingTests.java[tags=time-zone-column-examples-mapping-example]
----
@ -1899,7 +1899,7 @@ In the following example, the `java.time.Period` is going to be mapped to a `VAR
[[basic-jpa-convert-period-string-converter-example]]
.`java.time.Period` custom `AttributeConverter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/PeriodStringConverter.java[tags=basic-jpa-convert-period-string-converter-example]
----
@ -1910,7 +1910,7 @@ To make use of this custom converter, the `@Convert` annotation must decorate th
[[basic-jpa-convert-period-string-converter-mapping-example]]
.Entity using the custom `java.time.Period` `AttributeConverter` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/PeriodStringTest.java[tags=basic-jpa-convert-period-string-converter-mapping-example]
----
@ -1972,7 +1972,7 @@ Let's consider we have an application-specific `Money` type:
[[basic-hbm-attribute-converter-mapping-money-example]]
.Application-specific `Money` type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/hbm/Money.java[tags=basic-hbm-attribute-converter-mapping-money-example]
----
@ -1983,7 +1983,7 @@ Now, we want to use the `Money` type when mapping the `Account` entity:
[[basic-hbm-attribute-converter-mapping-account-example]]
.`Account` entity using the `Money` type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/hbm/Account.java[tags=basic-hbm-attribute-converter-mapping-account-example]
----
@ -1996,7 +1996,7 @@ to transform the `Money` type as a `Long`. For this purpose, we are going to use
[[basic-hbm-attribute-converter-mapping-moneyconverter-example]]
.`MoneyConverter` implementing the Jakarta Persistence `AttributeConverter` interface
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/hbm/MoneyConverter.java[tags=basic-hbm-attribute-converter-mapping-moneyconverter-example]
----
@ -2008,7 +2008,7 @@ attribute of the `property` element.
[[basic-hbm-attribute-converter-mapping-xml-config-example]]
.HBM mapping for `AttributeConverter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-resources}/mapping/converter/hbm/MoneyConverterHbmTest.hbm.xml[]
----
@ -2042,14 +2042,14 @@ then you can only change the entity attribute value by reassigning it to a new v
Considering we have the same `Period` entity attribute as illustrated in the <<basic-jpa-convert>> section:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/PeriodStringTest.java[tags=basic-jpa-convert-period-string-converter-mapping-example]
----
The only way to change the `span` attribute is to reassign it to a different value:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/PeriodStringTest.java[tags=basic-jpa-convert-period-string-converter-immutability-plan-example]
----
@ -2058,14 +2058,14 @@ include::{example-dir-basic-mapping}/converter/PeriodStringTest.java[tags=basic-
On the other hand, consider the following example where the `Money` type is a mutable.
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/MoneyConverterTest.java[tags=basic-jpa-convert-money-converter-mapping-example]
----
A mutable `Object` allows you to modify its internal structure, and Hibernate's dirty checking mechanism is going to propagate the change to the database:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/converter/MoneyConverterTest.java[tags=basic-jpa-convert-money-converter-mutability-plan-example]
----
@ -2088,7 +2088,7 @@ Assuming you have the following entity:
[[basic-attribute-converter-query-parameter-entity-example]]
.`Photo` entity with `AttributeConverter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-converter}/ConverterTest.java[tags=basic-attribute-converter-query-parameter-entity-example]
----
@ -2099,7 +2099,7 @@ And the `Caption` class looks as follows:
[[basic-attribute-converter-query-parameter-object-example]]
.`Caption` Java object
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-converter}/ConverterTest.java[tags=basic-attribute-converter-query-parameter-object-example]
----
@ -2110,7 +2110,7 @@ And we have an `AttributeConverter` to handle the `Caption` Java object:
[[basic-attribute-converter-query-parameter-converter-example]]
.`Caption` Java object AttributeConverter
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-converter}/ConverterTest.java[tags=basic-attribute-converter-query-parameter-converter-example]
----
@ -2121,7 +2121,7 @@ Traditionally, you could only use the DB data `Caption` representation, which in
[[basic-attribute-converter-query-parameter-converter-dbdata-example]]
.Filtering by the `Caption` property using the DB data representation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-converter}/ConverterTest.java[tags=basic-attribute-converter-query-parameter-converter-dbdata-example]
----
@ -2132,7 +2132,7 @@ In order to use the Java object `Caption` representation, you have to get the as
[[basic-attribute-converter-query-parameter-converter-object-example]]
.Filtering by the `Caption` property using the Java Object representation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-converter}/ConverterTest.java[tags=basic-attribute-converter-query-parameter-converter-object-example]
----
@ -2197,7 +2197,7 @@ We've covered many ways to specify basic value mappings so far. This section wi
[[basic-bitset-example-implicit]]
.Implicit BitSet mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetImplicitTests.java[tags=basic-bitset-example-implicit]
----
@ -2221,7 +2221,7 @@ This works well in most cases and is portable across Jakarta Persistence provide
[[basic-bitset-example-converter]]
.BitSet AttributeConverter
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetConverterTests.java[tags=basic-bitset-example-convert]
@ -2253,7 +2253,7 @@ for `BitSet` that maps values to `VARCHAR` for storage by default.
[[basic-bitset-example-java-type]]
.BitSet JavaTypeDescriptor
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJavaType.java[tags=basic-bitset-example-java-type]
----
@ -2265,7 +2265,7 @@ We can either apply that type locally using `@JavaType`
[[basic-bitset-example-java-type-local]]
.@JavaType
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJavaTypeTests.java[tags=basic-bitset-example-java-type-local,indent=0]
----
@ -2277,7 +2277,7 @@ to be used as the default whenever we encounter the `BitSet` type
[[basic-bitset-example-java-type-global]]
.@JavaTypeRegistration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJavaTypeRegistrationTests.java[tags=basic-bitset-example-java-type-global,indent=0]
----
@ -2303,7 +2303,7 @@ serialization.
[[basic-bitset-example-jdbc-type-code]]
.@JdbcTypeCode
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJdbcTypeCodeTests.java[tags=basic-bitset-example-jdbc-type-code,indent=0]
----
@ -2316,7 +2316,7 @@ In this example, `@JdbcTypeCode` has been used to indicate that the `JdbcType` r
[[basic-bitset-example-jdbc-type-local]]
.@JdbcType
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJdbcTypeTests.java[tags=basic-bitset-example-jdbc-type-local,indent=0]
----
@ -2331,7 +2331,7 @@ We could instead replace how Hibernate deals with all `VARBINARY` handling with
[[basic-bitset-example-jdbc-type-global]]
.@JdbcType
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/bitset/BitSetJdbcTypeRegistrationTests.java[tags=basic-bitset-example-jdbc-type-global,indent=0]
----
@ -2355,7 +2355,7 @@ This is usually double quotes, but SQL Server uses brackets and MySQL uses backt
[[basic-quoting-example]]
.Hibernate quoting
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/QuotingTest.java[tags=basic-quoting-example]
----
@ -2364,7 +2364,7 @@ include::{example-dir-basic-mapping}/basic/QuotingTest.java[tags=basic-quoting-e
[[basic-jpa-quoting-example]]
.Jakarta Persistence quoting
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/JpaQuotingTest.java[tags=basic-jpa-quoting-example]
----
@ -2377,7 +2377,7 @@ When saving the following `Product entity`, Hibernate generates the following SQ
[[basic-quoting-persistence-example]]
.Persisting a quoted column name
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/QuotingTest.java[tags=basic-quoting-persistence-example, indent=0]
----
@ -2408,7 +2408,7 @@ This way, we don't need to manually quote any identifier:
[[basic-auto-quoting-example]]
.Jakarta Persistence quoting
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/AutoQuotingTest.java[tags=basic-auto-quoting-example]
----
@ -2494,7 +2494,7 @@ It uses the database's `current_timestamp` function as the generated value
[[mapping-generated-provided-CurrentTimestamp-ex1]]
.`@UpdateTimestamp` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-generated}/CurrentTimestampAnnotationTests.java[tags=mapping-generated-CurrentTimestamp-ex1]
----
@ -2513,7 +2513,7 @@ Supports most temporal types (`java.time.Instant`, `java.util.Date`, `java.util.
[[mapping-generated-CreationTimestamp-example]]
.`@CreationTimestamp` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/generated/CreationTimestampTest.java[tags=mapping-generated-provided-creation-ex1]
----
@ -2534,7 +2534,7 @@ Supports most temporal types (`java.time.Instant`, `java.util.Date`, `java.util.
[[mapping-generated-provided-update-ex1]]
.`@UpdateTimestamp` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/generated/UpdateTimestampTest.java[tags=mapping-generated-provided-update-ex1]
----
@ -2553,7 +2553,7 @@ This is the legacy mapping for in-DB generated values.
[[mapping-generated-provided-Generated]]
.`@Generated` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/generated/GeneratedTest.java[tags=mapping-generated-provided-generated]
----
@ -2572,7 +2572,7 @@ Let's look at an example of generating UUID values. First the attribute mapping
[[mapping-generated-custom-ex1]]
.Custom generation mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-generated}/temporals/GeneratedUuidTests.java[tags=mapping-generated-custom-ex1]
----
@ -2584,7 +2584,7 @@ annotations provided by the application.
[[mapping-generated-custom-ex2]]
.Custom generation mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-generated}/temporals/GeneratedUuidTests.java[tags=mapping-generated-custom-ex2]
----
@ -2596,7 +2596,7 @@ Hibernate how to generate values for the attribute - here it will use the specif
[[mapping-generated-custom-ex3]]
.Custom generation mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-generated}/temporals/GeneratedUuidTests.java[tags=mapping-generated-custom-ex3]
----
@ -2618,7 +2618,7 @@ For example, if your database provides a set of data encryption functions, you c
[[mapping-column-read-and-write-example]]
.`@ColumnTransformer` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/../fetching/FetchingTest.java[tags=mapping-column-read-and-write-example]
----
@ -2629,7 +2629,7 @@ If a property uses more than one column, you must use the `forColumn` attribute
[[mapping-column-read-and-write-composite-type-example]]
.`@ColumnTransformer` `forColumn` attribute usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ColumnTransformerTest.java[tags=mapping-column-read-and-write-composite-type-example]
----
@ -2646,7 +2646,7 @@ The `write` expression, if specified, must contain exactly one '?' placeholder f
[[mapping-column-read-and-write-composite-type-persistence-example]]
.Persisting an entity with a `@ColumnTransformer` and a composite type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-basic-mapping}/basic/ColumnTransformerTest.java[tags=mapping-column-read-and-write-composite-type-persistence-example]
----

View File

@ -76,7 +76,7 @@ interpretation as to which classification it fits in to, using the following che
[[collection-list-ex]]
.Basic List Mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/list/EntityWithList.java[tags=collections-list-ex]
----
@ -104,7 +104,7 @@ The default column name that stores the index is derived from the attribute name
[[collection-list-ordercolumn-ex]]
.@OrderColumn
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/list/EntityWithOrderColumnList.java[tags=collections-list-ordercolumn-ex]
----
@ -121,7 +121,7 @@ cases using its `@ListIndexBase` annotation.
[[collection-list-indexbase-ex]]
.@ListIndexBase
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/list/EntityWithIndexBasedList.java[tags=collections-list-indexbase-ex]
----
@ -141,7 +141,7 @@ mapping sets according to the requirements of the `java.util.Set`.
[[collection-set-ex]]
.Basic Set Mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/set/EntityWithSet.java[tags=collections-set-ex]
----
@ -168,7 +168,7 @@ this implies that the element type is `Comparable`. E.g.
[[collection-sortedset-natural-ex]]
.@SortNatural
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/Name.java[tags=collections-name-ex]
@ -185,7 +185,7 @@ the `Names` as sorted by a `NameComparator`:
[[collection-sortedset-comparator-ex]]
.@SortComparator
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/NameComparator.java[tags=collections-name-comparator-ex]
@ -209,7 +209,7 @@ A `java.util.Map` is a collection of key/value pairs.
[[collection-map-ex]]
.Simple MAP mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/map/EntityWithMap.java[tags=collections-map-ex]
----
@ -223,7 +223,7 @@ Maps may be sorted naturally -
[[collection-sortedmap-natural-ex]]
.Naturally sorted MAP mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/map/EntityWithNaturallySortedMap.java[tags=example]
----
@ -234,7 +234,7 @@ or via a Comparator -
[[collection-sortedmap-ex]]
.Comparator sorted MAP mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/map/EntityWithSortedMap.java[tags=example]
----
@ -259,7 +259,7 @@ are handled is largely undefined.
[[collection-bag-ex]]
.Simple BAG mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/bag/EntityWithBagAsCollection.java[tags=collections-bag-ex]
----
@ -271,7 +271,7 @@ lists as bags. First an explicit annotation
[[collection-bag-list-ex]]
.@Bag
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/classification/bag/EntityWithBagAsList.java[tags=collections-bag-list-ex]
----
@ -409,7 +409,7 @@ cross between the ordered-ness of a `List` and the uniqueness of a `Set`. First
[[collection-type-ann-ex]]
.@CollectionType
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/semantics/TheEntityWithUniqueList.java[tags=ex-collections-custom-type-model]
----
@ -420,7 +420,7 @@ The mapping says to use the `UniqueListType` class for the mapping of the plural
[[collection-type-usertype-ex]]
.UniqueListType
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/semantics/UniqueListType.java[tags=collections-custom-type-ex]
----
@ -431,7 +431,7 @@ Most custom `UserCollectionType` implementations will want their own `Persistent
[[collection-type-usertype-wrapper-ex]]
.UniqueListWrapper
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/semantics/UniqueListWrapper.java[tags=collections-custom-semantics-ex]
----
@ -451,7 +451,7 @@ plural attributes of a given classification, Hibernate also provides the
[[collection-type-usertype-registration-ex]]
.UniqueListType Registration
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-collection}/semantics/TheEntityWithUniqueListRegistration.java[tags=ex-collections-custom-type-model]
----

View File

@ -176,7 +176,7 @@ However, for simple embeddable types, there is no such construct and so you need
[[embeddable-Target-example]]
.`@Target` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/TargetTest.java[tags=embeddable-Target-example]
----
@ -191,7 +191,7 @@ Assuming we have persisted the following `City` entity:
[[embeddable-Target-persist-example]]
.`@Target` persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/TargetTest.java[tags=embeddable-Target-persist-example]
----
@ -202,7 +202,7 @@ When fetching the `City` entity, the `coordinates` property is mapped by the `@T
[[embeddable-Target-fetching-example]]
.`@Target` fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/TargetTest.java[tags=embeddable-Target-fetching-example]
----
@ -223,7 +223,7 @@ The Hibernate-specific `@Parent` annotation allows you to reference the owner en
[[embeddable-Parent-example]]
.`@Parent` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/ParentTest.java[tags=embeddable-Parent-example]
----
@ -234,7 +234,7 @@ Assuming we have persisted the following `City` entity:
[[embeddable-Parent-persist-example]]
.`@Parent` persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/ParentTest.java[tags=embeddable-Parent-persist-example]
----
@ -245,7 +245,7 @@ When fetching the `City` entity, the `city` property of the embeddable type acts
[[embeddable-Parent-fetching-example]]
.`@Parent` fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-emeddable}/ParentTest.java[tags=embeddable-Parent-fetching-example]
----
@ -268,7 +268,7 @@ embeddable:
[[embeddable-instantiator-embeddable-ex]]
.`EmbeddableInstantiator` - Embeddable
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-embeddableinstantiator}/embedded/Name.java[tags=embeddable-instantiator-embeddable]
----
@ -280,7 +280,7 @@ conventions, in terms of constructor, a custom strategy for instantiation is nee
[[embeddable-instantiator-impl-ex]]
.`EmbeddableInstantiator` - Implementation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-embeddableinstantiator}/embedded/NameInstantiator.java[tags=embeddable-instantiator-impl]
----
@ -292,7 +292,7 @@ annotation can be used on the embedded attribute:
[[embeddable-instantiator-property-ex]]
.`@EmbeddableInstantiator` on attribute
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-embeddableinstantiator}/embedded/Person.java[tags=embeddable-instantiator-property]
----
@ -303,7 +303,7 @@ include::{example-dir-embeddableinstantiator}/embedded/Person.java[tags=embeddab
[[embeddable-instantiator-class-ex]]
.`@EmbeddableInstantiator` on class
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-embeddableinstantiator}/embeddable/Name.java[tags=embeddable-instantiator-class]
@ -319,7 +319,7 @@ on the <<embeddable-instantiator-class-ex,embeddable>>.
[[embeddable-instantiator-registration-ex]]
.`@EmbeddableInstantiatorRegistration`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-embeddableinstantiator}/registered/Person.java[tags=embeddable-instantiator-registration]
----
@ -344,7 +344,7 @@ For example, consider the following custom type:
[[embeddable-usertype-domain-ex]]
.`CompositeUserType` - Domain type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-compositeusertype}/embedded/Name.java[tags=embeddable-usertype-domain]
----
@ -356,7 +356,7 @@ conventions, a custom user type for instantiation and state access is needed.
[[embeddable-usertype-impl-ex]]
.`CompositeUserType` - Implementation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-compositeusertype}/embedded/NameCompositeUserType.java[tags=embeddable-usertype-impl]
----
@ -379,7 +379,7 @@ annotation can be used on the embedded and element collection attributes:
[[embeddable-usertype-property-ex]]
.`@CompositeType` on attribute
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-compositeusertype}/embedded/Person.java[tags=embeddable-usertype-property]
----
@ -391,7 +391,7 @@ when the application developer wants to apply the composite user type for all do
[[embeddable-usertype-registration-ex]]
.`@CompositeTypeRegistration`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-compositeusertype}/registered/Person.java[tags=embeddable-usertype-registration]
----

View File

@ -697,7 +697,7 @@ for identifier generators.
[[identifiers-generators-pooled-lo-optimizer-mapping-example]]
.Pooled-lo optimizer mapping using `@GenericGenerator` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-identifier}/PooledOptimizerTest.java[tag=identifiers-generators-pooled-lo-optimizer-mapping-example]
----
@ -708,7 +708,7 @@ Now, when saving 5 `Person` entities and flushing the Persistence Context after
[[identifiers-generators-pooled-lo-optimizer-persist-example]]
.Pooled-lo optimizer mapping using `@GenericGenerator` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-identifier}/PooledOptimizerTest.java[tag=identifiers-generators-pooled-lo-optimizer-persist-example]
----
@ -775,7 +775,7 @@ then Hibernate can use the `ROWID` pseudo-column for CRUD operations.
[[identifiers-rowid-mapping]]
.`@RowId` entity mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-identifier}/RowIdTest.java[tag=identifiers-rowid-mapping]
----
@ -786,7 +786,7 @@ Now, when fetching an entity and modifying it, Hibernate uses the `ROWID` pseudo
[[identifiers-rowid-example]]
.`@RowId` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-identifier}/RowIdTest.java[tag=identifiers-rowid-example]
----

View File

@ -37,7 +37,7 @@ If a specific entity is immutable, it is good practice to mark it with the `@Imm
.Immutable entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/entity/EntityImmutabilityTest.java[tags=entity-immutability-example]
----
@ -52,7 +52,7 @@ Considering the following entity is persisted in the database:
.Persisting an immutable entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/entity/EntityImmutabilityTest.java[tags=entity-immutability-persist-example]
----
@ -63,7 +63,7 @@ Hibernate will skip any modification, therefore no SQL `UPDATE` statement is exe
.The immutable entity ignores any update
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/entity/EntityImmutabilityTest.java[tags=entity-immutability-update-example]
----
@ -99,7 +99,7 @@ and internal-state sense. E.g.
.Immutable basic attribute
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/attribute/BasicAttributeMutabilityTests.java[tags=attribute-immutable-example]
----
@ -109,7 +109,7 @@ Changes to the `theDate` attribute are ignored.
.Immutable basic attribute change
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/attribute/BasicAttributeMutabilityTests.java[tags=attribute-immutable-managed-example]
----
@ -135,7 +135,7 @@ TIP:: While most immutable changes are simply discarded, modifying an immutable
.Persisting an immutable collection
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/attribute/PluralAttributeMutabilityTest.java[tags=collection-immutability-persist-example]
----
@ -147,7 +147,7 @@ For instance, we can still modify the entity name:
.Changing the mutable entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/attribute/PluralAttributeMutabilityTest.java[tags=collection-entity-update-example]
----
@ -162,7 +162,7 @@ However, when trying to modify the `events` collection:
.Immutable collections cannot be modified
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/attribute/PluralAttributeMutabilityTest.java[tags=collection-immutability-update-example]
----
@ -222,7 +222,7 @@ To understand the impact of internal-state mutability, consider the following en
.Basic mutability model
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/MutabilityBaselineEntity.java[tags=mutability-base-entity-example]
----
@ -233,7 +233,7 @@ update the value:
.Changing immutable value
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/MutabilityBaselineEntity.java[tags=mutability-base-string-example]
----
@ -247,7 +247,7 @@ with the immutable value, we can set the new value:
.Changing mutable value - setting
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/MutabilityBaselineEntity.java[tags=mutability-base-date-set-example]
----
@ -257,7 +257,7 @@ We can also mutate the existing value:
.Changing mutable value - mutating
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{mutability-example-dir}/MutabilityBaselineEntity.java[tags=mutability-base-date-mutate-example]
----

View File

@ -29,7 +29,7 @@ To help understand the type categorizations, let's look at a simple table and do
include::{extrasdir}/mapping-types-basic-example.sql[]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-mapping}/basic/TypeCategoryTest.java[tags=mapping-types-basic-example]
----

View File

@ -44,7 +44,7 @@ Hibernate is going to generate the following tables using the `hibernate.hbm2ddl
[[envers-audited-mapping-example]]
.Basic Envers entity mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-mapping-example]
----
@ -64,7 +64,7 @@ let's see how Envers auditing works when inserting, updating, and deleting the e
[[envers-audited-insert-example]]
.Auditing the entity `INSERT` operation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-insert-example]
----
@ -78,7 +78,7 @@ include::{extrasdir}/envers-audited-insert-example.sql[]
[[envers-audited-update-example]]
.Auditing the entity `UPDATE` operation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-update-example]
----
@ -92,7 +92,7 @@ include::{extrasdir}/envers-audited-update-example.sql[]
[[envers-audited-delete-example]]
.Auditing the entity `DELETE` operation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-delete-example]
----
@ -120,7 +120,7 @@ The audit (history) of an entity can be accessed using the `AuditReader` interfa
[[envers-audited-revisions-example]]
.Getting a list of revisions for the `Customer` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-revisions-example]
----
@ -136,7 +136,7 @@ Using the previously fetched revisions, we can now inspect the state of the `Cus
[[envers-audited-rev1-example]]
.Getting the first revision for the `Customer` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-rev1-example]
----
@ -159,7 +159,7 @@ The same goes for the second revision associated with the `UPDATE` statement.
[[envers-audited-rev2-example]]
.Getting the second revision for the `Customer` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-rev2-example]
----
@ -170,7 +170,7 @@ For the deleted entity revision, Envers throws a `NoResultException` since the e
[[envers-audited-rev3-example]]
.Getting the third revision for the `Customer` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-rev3-example]
----
@ -184,7 +184,7 @@ all attributes, except for the entity identifier, are going to be `null`.
[[envers-audited-rev4-example]]
.Getting the third revision for the `Customer` entity without getting a `NoResultException`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/DefaultAuditTest.java[tags=envers-audited-rev4-example]
----
@ -411,7 +411,7 @@ First, you need to configure the `ValidityAuditStrategy`:
[[envers-audited-validity-configuration-example]]
.Configuring the `ValidityAuditStrategy`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/ValidityStrategyAuditTest.java[tags=envers-audited-validity-configuration-example]
----
@ -512,7 +512,7 @@ Considering we have a `CurrentUser` utility which stores the currently logged us
[[envers-revisionlog-CurrentUser-example]]
.`CurrentUser` utility
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/CustomRevisionEntityTest.java[tags=envers-revisionlog-CurrentUser-example]
----
@ -523,7 +523,7 @@ Now, we need to provide a custom `@RevisionEntity` to store the currently logged
[[envers-revisionlog-RevisionEntity-example]]
.Custom `@RevisionEntity` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/CustomRevisionEntityTest.java[tags=envers-revisionlog-RevisionEntity-example]
----
@ -536,7 +536,7 @@ of `RevisionEntity` instances.
[[envers-revisionlog-RevisionListener-example]]
.Custom `@RevisionListener` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/CustomRevisionEntityTest.java[tags=envers-revisionlog-RevisionListener-example]
----
@ -560,7 +560,7 @@ Now, when inserting a `Customer` entity, Envers generates the following statemen
[[envers-revisionlog-RevisionEntity-persist-example]]
.Auditing using the custom `@RevisionEntity` instance
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/CustomRevisionEntityTest.java[tags=envers-revisionlog-RevisionEntity-persist-example]
----
@ -611,7 +611,7 @@ Tracking of modified entity names can be enabled in three different ways:
In this case `org.hibernate.envers.DefaultTrackingModifiedEntitiesRevisionEntity` will be implicitly used as the revision log entity.
. Create a custom revision entity that extends `org.hibernate.envers.DefaultTrackingModifiedEntitiesRevisionEntity` class.
+
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditDefaultTrackingTest.java[tags=envers-tracking-modified-entities-revchanges-example]
----
@ -619,7 +619,7 @@ include::{example-dir-envers}/EntityTypeChangeAuditDefaultTrackingTest.java[tags
. Mark an appropriate field of a custom revision entity with `@org.hibernate.envers.ModifiedEntityNames` annotation.
The property is required to be of `Set<String>` type.
+
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTest.java[tags=envers-tracking-modified-entities-revchanges-example]
----
@ -629,7 +629,7 @@ Considering we have a `Customer` entity illustrated by the following example:
[[envers-tracking-modified-entities-revchanges-before-rename-example]]
.`Customer` entity before renaming
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTest.java[tags=envers-tracking-modified-entities-revchanges-before-rename-example]
----
@ -641,7 +641,7 @@ Envers is going to insert a new record in the `REVCHANGES` table with the previo
[[envers-tracking-modified-entities-revchanges-after-rename-example]]
.`Customer` entity after renaming
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTest.java[tags=envers-tracking-modified-entities-revchanges-after-rename-example]
----
@ -665,7 +665,7 @@ added, modified or removed within current revision boundaries.
[[envers-tracking-modified-entities-revchanges-EntityTrackingRevisionListener-example]]
.The `EntityTrackingRevisionListener` implementation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTrackingRevisionListenerTest.java[tags=envers-tracking-modified-entities-revchanges-EntityTrackingRevisionListener-example]
----
@ -676,7 +676,7 @@ The `CustomTrackingRevisionListener` adds the fully-qualified class name to the
[[envers-tracking-modified-entities-revchanges-RevisionEntity-example]]
.The `RevisionEntity` using the custom `EntityTrackingRevisionListener`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTrackingRevisionListenerTest.java[tags=envers-tracking-modified-entities-revchanges-RevisionEntity-example]
----
@ -687,7 +687,7 @@ The `CustomTrackingRevisionEntity` contains a `@OneToMany` list of `ModifiedType
[[envers-tracking-modified-entities-revchanges-EntityType-example]]
.The `EntityType` encapsulates the entity type name before a class name modification
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTrackingRevisionListenerTest.java[tags=envers-tracking-modified-entities-revchanges-EntityType-example]
----
@ -698,7 +698,7 @@ Now, when fetching the `CustomTrackingRevisionEntity`, you can get access to the
[[envers-tracking-modified-entities-revchanges-query-example]]
.Getting the `EntityType` through the `CustomTrackingRevisionEntity`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTrackingRevisionListenerTest.java[tags=envers-tracking-modified-entities-revchanges-query-example]
----
@ -731,7 +731,7 @@ Because of costs mentioned, it is recommended to enable the feature selectively,
[[envers-tracking-properties-changes-mapping-example]]
.Mapping for tracking entity changes at the property level
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/ModifiedFlagsAuditTest.java[tags=envers-tracking-properties-changes-mapping-example]
----
@ -747,7 +747,7 @@ As you can see, every property features a `_MOD` column (e.g. `createdOn_MOD`) i
[[envers-tracking-properties-changes-example]]
.Tracking entity changes at the property level example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/ModifiedFlagsAuditTest.java[tags=envers-tracking-properties-changes-example]
----
@ -862,7 +862,7 @@ The entry point for this type of queries is:
[[entities-at-revision-example]]
.Getting the `Customer` entity at a given revision
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-at-revision-example]
----
@ -879,7 +879,7 @@ For example, to select only entities where the `firstName` property is equal to
[[entities-filtering-example]]
.Getting the `Customer` audit log with a given `firstName` attribute value
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-filtering-example]
----
@ -891,7 +891,7 @@ you can use either the target entity or its identifier.
[[entities-filtering-by-entity-example]]
.Getting the `Customer` entities whose `address` attribute matches the given entity reference
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-filtering-by-entity-example]
----
@ -907,7 +907,7 @@ The same SQL is generated even if we provide the identifier instead of the targe
[[entities-filtering-by-entity-identifier-example]]
.Getting the `Customer` entities whose `address` identifier matches the given entity identifier
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-filtering-by-entity-identifier-example]
----
@ -918,7 +918,7 @@ Apart from strict equality matching, you can also use an `IN` clause to provide
[[entities-in-clause-filtering-by-entity-identifier-example]]
.Getting the `Customer` entities whose `address` identifier matches one of the given entity identifiers
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-in-clause-filtering-by-entity-identifier-example]
----
@ -937,7 +937,7 @@ A full query, can look for example like this:
[[entities-filtering-and-pagination]]
.Getting the `Customer` entities using filtering and pagination
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=entities-filtering-and-pagination]
----
@ -954,7 +954,7 @@ include::{extrasdir}/entities-filtering-and-pagination.sql[]
The entry point for this type of queries is:
[[revisions-of-entity-query-example]]
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=revisions-of-entity-query-example]
----
@ -974,7 +974,7 @@ Using these methods, you can order the query results by revision number, set pro
For example, the following query will select the smallest revision number, at which entity of class `MyEntity` with id `entityId` has changed, after revision number 2:
[[revisions-of-entity-query-by-revision-number-example]]
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=revisions-of-entity-query-by-revision-number-example]
----
@ -986,7 +986,7 @@ attribute was larger then a given value,
you can run the following query:
[[revisions-of-entity-query-minimize-example]]
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=revisions-of-entity-query-minimize-example]
----
@ -1017,7 +1017,7 @@ an aggregate query based on the entity instance primary key.
For example, if you wanted to locate all customers but only wanted to retrieve the instances with the
maximum revision number, you would use the following query:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=aggregate-max-revision-with-entity-example]
----
@ -1038,7 +1038,7 @@ First, you must make sure that your entity can track _modification flags_:
[[envers-tracking-properties-changes-queries-entity-example]]
.Valid only when audit logging tracks entity attribute modification flags
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditWithModifiedFlagTest.java[tags=envers-tracking-properties-changes-queries-entity-example]
----
@ -1050,7 +1050,7 @@ for which the `lastName` property has changed.
[[envers-tracking-properties-changes-queries-hasChanged-example]]
.Getting all `Customer` revisions for which the `lastName` attribute has changed
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditWithModifiedFlagTest.java[tags=envers-tracking-properties-changes-queries-hasChanged-example]
----
@ -1070,7 +1070,7 @@ Of course, nothing prevents users from combining `hasChanged` condition with som
[[envers-tracking-properties-changes-queries-hasChanged-and-hasNotChanged-example]]
.Getting all `Customer` revisions for which the `lastName` attribute has changed and the `firstName` attribute has not changed
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditWithModifiedFlagTest.java[tags=envers-tracking-properties-changes-queries-hasChanged-and-hasNotChanged-example]
----
@ -1087,7 +1087,7 @@ we have to use the `forEntitiesModifiedAtRevision` query:
[[envers-tracking-properties-changes-queries-at-revision-example]]
.Getting the `Customer` entity for a given revision if the `lastName` attribute has changed and the `firstName` attribute has not changed
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditWithModifiedFlagTest.java[tags=envers-tracking-properties-changes-queries-at-revision-example]
----
@ -1114,7 +1114,7 @@ You can now obtain this information easily by using the following query:
.Querying entity revisions including property names modified.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
List results = AuditReaderFactory.get( entityManager )
.createQuery()
@ -1145,12 +1145,12 @@ This basic query allows retrieving entity names and corresponding Java classes c
[[envers-tracking-modified-entities-queries-example]]
.Retrieving entity names and corresponding Java classes changed in a specified revision
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTest.java[tags=envers-tracking-modified-entities-queries-example1]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/EntityTypeChangeAuditTest.java[tags=envers-tracking-modified-entities-queries-example2]
----
@ -1191,7 +1191,7 @@ The basis for creating an entity relation join query is as follows:
[[envers-querying-entity-relation-inner-join]]
.INNER JOIN entity audit query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=envers-querying-entity-relation-inner-join]
----
@ -1200,7 +1200,7 @@ include::{example-dir-envers}/QueryAuditTest.java[tags=envers-querying-entity-re
[[envers-querying-entity-relation-left-join]]
.LEFT JOIN entity audit query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=envers-querying-entity-relation-left-join]
----
@ -1214,7 +1214,7 @@ you can use the following query:
[[envers-querying-entity-relation-join-restriction]]
.Filtering the join relation with a WHERE clause predicate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditTest.java[tags=envers-querying-entity-relation-join-restriction]
----
@ -1233,7 +1233,7 @@ with the country attribute of the address property being `România`:
[[envers-querying-entity-relation-nested-join-restriction]]
.Filtering a nested join relation with a WHERE clause predicate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-querying-entity-relation-nested-join-restriction]
----
@ -1252,7 +1252,7 @@ having the `address` in `Cluj-Napoca` or the `address` does _not_ have any count
[[envers-querying-entity-relation-join-multiple-restrictions]]
.Filtering a join relation using multiple predicates
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-querying-entity-relation-join-multiple-restrictions]
----
@ -1276,7 +1276,7 @@ where the country name is `România` or that the `Customer` lives in `Cluj-Napoc
[[envers-querying-entity-relation-nested-join-multiple-restrictions]]
.Filtering a nested join relation using multiple predicates
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-querying-entity-relation-nested-join-multiple-restrictions]
----
@ -1294,7 +1294,7 @@ Assuming the `Customer` and the `Address` were previously changed as follows:
[[envers-querying-entity-relation-nested-join-multiple-restrictions-combined-entities]]
.Changing the `Address` to match the `Country` name
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-querying-entity-relation-nested-join-multiple-restrictions-combined-entities]
----
@ -1306,7 +1306,7 @@ where the `city` property of the `address` attribute equals the `name` of the as
[[envers-querying-entity-relation-nested-join-multiple-restrictions-combined]]
.Filtering a nested join relation using multiple predicates
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-querying-entity-relation-nested-join-multiple-restrictions-combined]
----
@ -1430,7 +1430,7 @@ For the following entities, Hibernate is going to generate the following databas
[[envers-generateschema-example]]
.Filtering a nested join relation using multiple predicates
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-envers}/QueryAuditAdressCountryTest.java[tags=envers-generateschema-example]
----

View File

@ -20,7 +20,7 @@ The following example shows an `Interceptor` implementation that automatically l
[[events-interceptors-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/InterceptorTest.java[tags=events-interceptors-example]
----
@ -37,7 +37,7 @@ A Session-scoped interceptor is specified when a session is opened.
[[events-interceptors-session-scope-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/InterceptorTest.java[tags=events-interceptors-session-scope-example]
----
@ -50,7 +50,7 @@ Ensure that you do not store session-specific states since multiple sessions wil
[[events-interceptors-session-factory-scope-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/InterceptorTest.java[tags=events-interceptors-session-factory-scope-example]
----
@ -82,12 +82,12 @@ Here is an example of a custom load event listener:
[[events-interceptors-load-listener-example]]
.Custom `LoadListener` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/ListenerTest.java[tags=events-interceptors-load-listener-example-part1]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/ListenerTest.java[tags=events-interceptors-load-listener-example-part2]
----
@ -135,7 +135,7 @@ The entity listener class is then associated with the entity using the `jakarta.
[[events-jpa-callbacks-example]]
.Example of specifying Jakarta Persistence callbacks
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/ListenerTest.java[tags=events-jpa-callbacks-example]
----
@ -173,7 +173,7 @@ Default entity listeners can only be defined in XML mapping files.
[[events-default-listener-mapping-example]]
.Default event listener mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListener.java[tags=events-default-listener-mapping-example]
----
@ -186,12 +186,12 @@ include::{example-dir-event-resources}/DefaultEntityListener-orm.xml[tags=events
Considering that all entities extend the `BaseEntity` class:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/BaseEntity.java[tags=events-default-listener-mapping-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListenerTest.java[tags=events-default-listener-mapping-example]
----
@ -201,7 +201,7 @@ When persisting a `Person` or `Book` entity, the `createdOn` is going to be set
[[events-default-listener-persist-example]]
.Default event listener persist event
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListenerTest.java[tags=events-default-listener-persist-example]
----
@ -217,7 +217,7 @@ When updating a `Person` or `Book` entity, the `updatedOn` is going to be set by
[[events-default-listener-update-example]]
.Default event listener update event
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListenerTest.java[tags=events-default-listener-update-example]
----
@ -242,7 +242,7 @@ while `@ExcludeSuperclassListeners` is used to ignore the default entity listene
[[events-exclude-default-listener-mapping-example]]
.Exclude default event listener mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListenerTest.java[tags=events-exclude-default-listener-mapping-example]
----
@ -255,7 +255,7 @@ because the `Publisher` entity was marked with the `@ExcludeDefaultListeners` an
[[events-exclude-default-listener-persist-example]]
.Excluding default event listener events
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-event}/DefaultEntityListenerTest.java[tags=events-exclude-default-listener-persist-example]
----

View File

@ -61,7 +61,7 @@ To see the difference between direct fetching and entity queries in regard to ea
[[fetching-direct-vs-query-domain-model-example]]
.Domain model
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/DirectVsQueryFetchingTest.java[tags=fetching-direct-vs-query-domain-model-example]
----
@ -74,7 +74,7 @@ When issuing a direct entity fetch, Hibernate executed the following SQL query:
[[fetching-direct-vs-query-direct-fetching-example]]
.Direct fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/DirectVsQueryFetchingTest.java[tags=fetching-direct-vs-query-direct-fetching-example]
----
@ -92,7 +92,7 @@ On the other hand, if you are using an entity query that does not contain a `JOI
[[fetching-direct-vs-query-entity-query-example]]
.Entity query fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/DirectVsQueryFetchingTest.java[tags=fetching-direct-vs-query-entity-query-example]
----
@ -122,7 +122,7 @@ Let's consider these topics as it relates to a sample domain model and a few use
[[fetching-strategies-domain-model-example]]
.Sample domain model
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-domain-model-example]
----
@ -146,7 +146,7 @@ Let's assume that login only requires access to the `Employee` information, not
[[fetching-strategies-no-fetching-example]]
.No fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-no-fetching-example]
----
@ -160,7 +160,7 @@ If the login process does not need access to the `Employee` information specific
[[fetching-strategies-no-fetching-scalar-example]]
.No fetching (scalar) example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-no-fetching-scalar-example]
----
@ -175,7 +175,7 @@ Certainly access to the `Employee` is needed, as is the collection of `Projects`
[[fetching-strategies-dynamic-fetching-jpql-example]]
.Dynamic JPQL fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-dynamic-fetching-jpql-example]
----
@ -184,7 +184,7 @@ include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-dynam
[[fetching-strategies-dynamic-fetching-criteria-example]]
.Dynamic query fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchingTest.java[tags=fetching-strategies-dynamic-fetching-criteria-example]
----
@ -208,12 +208,12 @@ Below is a `fetch graph` dynamic fetching example:
[[fetching-strategies-dynamic-fetching-entity-graph-example]]
.Fetch graph example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphFetchingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-mapping-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphFetchingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-example]
----
@ -242,7 +242,7 @@ and we'd like to fetch the `department` for the `Employee` child association.
[[fetching-strategies-dynamic-fetching-entity-subgraph-mapping-example]]
.Fetch graph with a subgraph mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphFetchingTest.java[tags=fetching-strategies-dynamic-fetching-entity-subgraph-mapping-example]
----
@ -253,7 +253,7 @@ When fetching this entity graph, Hibernate generates the following SQL query:
[[fetching-strategies-dynamic-fetching-entity-subgraph-example]]
.Fetch graph with a subgraph mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphFetchingTest.java[tags=fetching-strategies-dynamic-fetching-entity-subgraph-example]
----
@ -302,7 +302,7 @@ the Jakarta Persistence specification proper.
.Parsing a simple graph
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-parsing-example-1]
----
@ -317,7 +317,7 @@ to the end of the attribute name.
.Parsing an entity key graph
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-parsing-key-example-1]
----
@ -325,7 +325,7 @@ include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-d
.Parsing a map key graph
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-parsing-key-example-2]
----
@ -336,7 +336,7 @@ Parsing can also handle sub-type specific sub-graphs. For example, given an ent
type is the `LegalEntity` base type we might have:
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
responsibleParty(Corporation: ceo)
----
@ -345,7 +345,7 @@ responsibleParty(Corporation: ceo)
We can even duplicate the attribute names to apply different sub-type sub-graphs:
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
responsibleParty(taxIdNumber), responsibleParty(Corporation: ceo), responsibleParty(NonProfit: sector)
----
@ -357,7 +357,7 @@ effectively merging the 2 AttributeNode specifications together. In other words
creates a single AttributeNode with 3 distinct SubGraphs. It is functionally the same as calling:
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
Class<Invoice> invoiceClass = ...;
jakarta.persistence.EntityGraph<Invoice> invoiceGraph = entityManager.createEntityGraph( invoiceClass );
@ -376,7 +376,7 @@ the previous example can also be built by combining separate aspect graphs into
.Combining multiple graphs into one
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/GraphParsingTest.java[tags=fetching-strategies-dynamic-fetching-entity-graph-merging-example]
----
@ -393,12 +393,12 @@ So we would leverage a fetch profile.
[[fetching-strategies-dynamic-fetching-profile-example]]
.Fetch profile example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/ProfileFetchingTest.java[tags=fetching-strategies-dynamic-fetching-profile-mapping-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/ProfileFetchingTest.java[tags=fetching-strategies-dynamic-fetching-profile-example]
----
@ -419,7 +419,7 @@ Considering the following entity mapping:
[[fetching-batch-mapping-example]]
.`@BatchSize` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/BatchFetchingTest.java[tags=fetching-batch-mapping-example]
----
@ -432,7 +432,7 @@ the `@BatchSize` annotations allows us to load multiple `Employee` entities in a
[[fetching-batch-fetching-example]]
.`@BatchSize` fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/BatchFetchingTest.java[tags=fetching-batch-fetching-example]
----
@ -487,7 +487,7 @@ To demonstrate how `FetchMode.SELECT` works, consider the following entity mappi
[[fetching-strategies-fetch-mode-select-mapping-example]]
.`FetchMode.SELECT` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeSelectTest.java[tags=fetching-strategies-fetch-mode-select-mapping-example]
----
@ -500,7 +500,7 @@ collection using a secondary `SELECT` statement upon accessing the child collect
[[fetching-strategies-fetch-mode-select-example]]
.`FetchMode.SELECT` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeSelectTest.java[tags=fetching-strategies-fetch-mode-select-example]
----
@ -523,7 +523,7 @@ To demonstrate how `FetchMode.SUBSELECT` works, we are going to modify the <<fet
[[fetching-strategies-fetch-mode-subselect-mapping-example]]
.`FetchMode.SUBSELECT` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeSubselectTest.java[tags=fetching-strategies-fetch-mode-subselect-mapping-example]
----
@ -539,7 +539,7 @@ Instead of passing all entity identifiers, Hibernate simply reruns the previous
[[fetching-strategies-fetch-mode-subselect-example]]
.`FetchMode.SUBSELECT` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeSubselectTest.java[tags=fetching-strategies-fetch-mode-subselect-example]
----
@ -559,7 +559,7 @@ To demonstrate how `FetchMode.JOIN` works, we are going to modify the <<fetching
[[fetching-strategies-fetch-mode-join-mapping-example]]
.`FetchMode.JOIN` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeJoinTest.java[tags=fetching-strategies-fetch-mode-join-mapping-example]
----
@ -585,7 +585,7 @@ Hibernate is going to avoid the secondary query by issuing an OUTER JOIN for the
[[fetching-strategies-fetch-mode-join-example]]
.`FetchMode.JOIN` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/FetchModeJoinTest.java[tags=fetching-strategies-fetch-mode-join-example]
----
@ -616,7 +616,7 @@ Each element is fetched individually using a secondary query.
[[fetching-LazyCollection-domain-model-example]]
.`LazyCollectionOption.EXTRA` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/LazyCollectionTest.java[tags=fetching-LazyCollection-domain-model-example]
----
@ -637,7 +637,7 @@ Now, considering we have the following entities:
[[fetching-LazyCollection-persist-example]]
.`LazyCollectionOption.EXTRA` Domain Model example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/LazyCollectionTest.java[tags=fetching-LazyCollection-persist-example]
----
@ -649,7 +649,7 @@ Hibernate generates the following SQL statements:
[[fetching-LazyCollection-select-example]]
.`LazyCollectionOption.EXTRA` fetching example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-fetching}/LazyCollectionTest.java[tags=fetching-LazyCollection-select-example]
----

View File

@ -43,7 +43,7 @@ In the following example, an entity is persisted, and then the transaction is co
[[flushing-auto-flush-commit-example]]
.Automatic flushing on commit
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-commit-example]
----
@ -70,7 +70,7 @@ A flush may also be triggered when executing an entity query.
[[flushing-auto-flush-jpql-example]]
.Automatic flushing on JPQL/HQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-jpql-example]
----
@ -86,7 +86,7 @@ The reason why the `Advertisement` entity query didn't trigger a flush is that t
[[flushing-auto-flush-jpql-entity-example]]
.Automatic flushing on JPQL/HQL entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-jpql-entity-example]
----
@ -97,7 +97,7 @@ When querying for a `Person` entity, the flush is triggered prior to executing t
[[flushing-auto-flush-jpql-overlap-example]]
.Automatic flushing on JPQL/HQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-jpql-overlap-example]
----
@ -117,7 +117,7 @@ When executing a native SQL query, a flush is always triggered when using the `E
[[flushing-auto-flush-sql-example]]
.Automatic flushing on native SQL using `EntityManager`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-sql-example]
----
@ -129,7 +129,7 @@ the `Session` API will trigger a flush automatically when executing a native que
[[flushing-auto-flush-sql-native-example]]
.Automatic flushing on native SQL using `Session`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/HibernateAutoFlushTest.java[tags=flushing-auto-flush-sql-native-example]
----
@ -140,7 +140,7 @@ To flush the `Session`, the query must use a synchronization:
[[flushing-auto-flush-sql-synchronization-example]]
.Automatic flushing on native SQL with `Session` synchronization
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AutoFlushTest.java[tags=flushing-auto-flush-sql-synchronization-example]
----
@ -161,7 +161,7 @@ When executing a JPQL query, the persistence context is only flushed when the cu
[[flushing-commit-flush-jpql-example]]
.`COMMIT` flushing on JPQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/CommitFlushTest.java[tags=flushing-commit-flush-jpql-example]
----
@ -177,7 +177,7 @@ Because the Jakarta Persistence doesn't impose a strict rule on delaying flushin
[[flushing-commit-flush-sql-example]]
.`COMMIT` flushing on native SQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/CommitFlushTest.java[tags=flushing-commit-flush-sql-example]
----
@ -201,7 +201,7 @@ The `ALWAYS` flush mode triggers a persistence context flush even when executing
[[flushing-always-flush-sql-example]]
.`COMMIT` flushing on native SQL
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/AlwaysFlushTest.java[tags=flushing-always-flush-sql-example]
----
@ -221,7 +221,7 @@ Hibernate also provides a `MANUAL` flush mode so the persistence context can onl
[[flushing-manual-flush-example]]
.`MANUAL` flushing
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/ManualFlushTest.java[tags=flushing-manual-flush-example]
----
@ -256,7 +256,7 @@ To visualize how this works, consider the following example:
[[flushing-order-example]]
.Flush operation order
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-flushing}/FlushOrderTest.java[tags=flushing-order-example]
----

View File

@ -79,7 +79,7 @@ The version number mechanism for optimistic locking is provided through a `@Vers
[[locking-optimistic-version-number-example]]
.@Version annotation
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/OptimisticLockingTest.java[tags=locking-optimistic-version-number-example,indent=0]
----
@ -108,7 +108,7 @@ Timestamping is automatically used if you specify the `@Version` annotation on a
[[locking-optimistic-version-timestamp-example]]
.Using timestamps for optimistic locking
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/OptimisticLockingTest.java[tags=locking-optimistic-version-timestamp-example,indent=0]
----
@ -119,7 +119,7 @@ The timestamp can also be generated by the database, instead of by the VM, using
[[locking-optimistic-version-timestamp-source-mapping-example]]
.Database-generated version timestamp mapping
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/VersionSourceTest.java[tags=locking-optimistic-version-timestamp-source-mapping-example,indent=0]
----
@ -130,7 +130,7 @@ Now, when persisting a `Person` entity, Hibernate calls the database-specific cu
[[locking-optimistic-version-timestamp-source-persist-example]]
.Database-generated version timestamp example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/VersionSourceTest.java[tags=locking-optimistic-version-timestamp-source-persist-example,indent=0]
----
@ -152,7 +152,7 @@ as illustrated in the following example.
[[locking-optimistic-exclude-attribute-mapping-example]]
.@OptimisticLock mapping example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/OptimisticLockTest.java[tags=locking-optimistic-exclude-attribute-mapping-example,indent=0]
----
@ -164,7 +164,7 @@ the two concurrent transactions are not going to conflict as illustrated by the
[[locking-optimistic-exclude-attribute-example]]
.@OptimisticLock exlude attribute example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/OptimisticLockTest.java[tags=locking-optimistic-exclude-attribute-example,indent=0]
----
@ -354,7 +354,7 @@ The scope can either be `NORMAL` (default value) or `EXTENDED`. The `EXTENDED` s
[[locking-jpa-query-hints-timeout-example]]
.`jakarta.persistence.lock.timeout` example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/ExplicitLockingTest.java[tags=locking-jpa-query-hints-timeout-example,indent=0]
----
@ -384,7 +384,7 @@ The following example shows how to obtain a shared database lock.
[[locking-session-lock-example]]
.`session.lock()` example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/ExplicitLockingTest.java[tags=locking-session-lock-example,indent=0]
----
@ -410,7 +410,7 @@ For this reason, Hibernate uses secondary selects to lock the previously fetched
[[locking-follow-on-example]]
.Follow-on-locking example
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/ExplicitLockingTest.java[tags=locking-follow-on-example,indent=0]
----
@ -429,7 +429,7 @@ To avoid the N+1 query problem, a separate query can be used to apply the lock u
[[locking-follow-on-secondary-query-example]]
.Secondary query entity locking
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/ExplicitLockingTest.java[tags=locking-follow-on-secondary-query-example,indent=0]
----
@ -450,7 +450,7 @@ Even more important is that you can overrule the default follow-on-locking detec
[[locking-follow-on-explicit-example]]
.Disabling the follow-on-locking mechanism explicitly
====
[source, JAVA,indent=0]
[source, java,indent=0]
----
include::{example-dir-locking}/ExplicitLockingTest.java[tags=locking-follow-on-explicit-example,indent=0]
----

View File

@ -69,7 +69,7 @@ The API is really just defined by passing the tenant identifier as part of openi
[[multitenacy-hibernate-session-example]]
.Specifying tenant identifier from `SessionFactory`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/AbstractMultiTenancyTest.java[tags=multitenacy-hibernate-session-example]
----
@ -84,7 +84,7 @@ annotated `@TenantId`.
[[multitenacy-hibernate-TenantId-example]]
.A `@TenantId` usage example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
@Entity
public class Account {
@ -128,7 +128,7 @@ The following example portrays a `MultiTenantConnectionProvider` implementation
[[multitenacy-hibernate-ConfigurableMultiTenantConnectionProvider-example]]
.A `MultiTenantConnectionProvider` implementation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/ConfigurableMultiTenantConnectionProvider.java[tags=multitenacy-hibernate-ConfigurableMultiTenantConnectionProvider-example]
----
@ -139,7 +139,7 @@ The `ConfigurableMultiTenantConnectionProvider` can be set up as follows:
[[multitenacy-hibernate-MultiTenantConnectionProvider-example]]
.A `MultiTenantConnectionProvider` usage example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/AbstractMultiTenancyTest.java[tags=multitenacy-hibernate-MultiTenantConnectionProvider-example]
----
@ -150,7 +150,7 @@ When using multitenancy, it's possible to save an entity with the same identifie
[[multitenacy-hibernate-same-entity-example]]
.An example of saving entities with the same identifier across different tenants
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/AbstractMultiTenancyTest.java[tags=multitenacy-multitenacy-hibernate-same-entity-example]
----
@ -196,7 +196,7 @@ For instance, each tenant could specify a different time zone configuration.
[[multitenacy-hibernate-timezone-configuration-registerConnectionProvider-call-example]]
.Registering the tenant-specific time zone information
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-timezone-configuration-registerConnectionProvider-call-example]
----
@ -207,7 +207,7 @@ The `registerConnectionProvider` method is used to define the tenant-specific co
[[multitenacy-hibernate-timezone-configuration-registerConnectionProvider-example]]
.The `registerConnectionProvider` method used for defining the tenant-specific context
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-timezone-configuration-registerConnectionProvider-example]
----
@ -215,7 +215,7 @@ include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=m
For our example, the tenant-specific context is held in the `connectionProviderMap` and `timeZoneTenantMap`.
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-timezone-configuration-context-example]
----
@ -226,7 +226,7 @@ we could also configure the `Session` to use the tenant-specific time zone.
[[multitenacy-hibernate-timezone-configuration-session-example]]
.The Hibernate `Session` can be configured using the tenant-specific context
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-timezone-configuration-session-example]
----
@ -239,7 +239,7 @@ even if the currently running JVM uses a different time zone.
[[multitenacy-hibernate-applying-timezone-configuration-example]]
.The `useTenantTimeZone` allows you to persist a `Timestamp` in the provided time zone
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-applying-timezone-configuration-example]
----
@ -252,7 +252,7 @@ test output.
[[multitenacy-hibernate-not-applying-timezone-configuration-example]]
.With the `useTenantTimeZone` property set to `false`, the `Timestamp` is fetched in the tenant-specific time zone
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-multitenancy}/DatabaseTimeZoneMultiTenancyTest.java[tags=multitenacy-hibernate-not-applying-timezone-configuration-example]
----

View File

@ -29,7 +29,7 @@ This behavior is explicitly controllable through the `@org.hibernate.annotations
[[BytecodeEnhancement-lazy-loading-example]]
.`@LazyGroup` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnhancement-lazy-loading-example]
----
@ -67,7 +67,7 @@ Consider a domain model with a normal `Person`/`Book` bidirectional association:
[[BytecodeEnhancement-dirty-tracking-bidirectional-example]]
.Bidirectional association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnhancement-dirty-tracking-bidirectional-example]
----
@ -76,7 +76,7 @@ include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnh
[[BytecodeEnhancement-dirty-tracking-bidirectional-incorrect-usage-example]]
.Incorrect normal Java usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnhancement-dirty-tracking-bidirectional-incorrect-usage-example]
----
@ -87,7 +87,7 @@ This blows up in normal Java usage. The correct normal Java usage is:
[[BytecodeEnhancement-dirty-tracking-bidirectional-correct-usage-example]]
.Correct normal Java usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnhancement-dirty-tracking-bidirectional-correct-usage-example]
----

View File

@ -28,7 +28,7 @@ Jakarta Persistence defines an incredibly useful method to allow applications ac
[[pc-unwrap-example]]
.Accessing Hibernate APIs from Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-unwrap-example]
----
@ -45,7 +45,7 @@ You can make it persistent by associating it to either an `org.hibernate.Session
[[pc-persist-jpa-example]]
.Making an entity persistent with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-persist-jpa-example]
----
@ -54,7 +54,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-persist-jpa-exampl
[[pc-persist-native-example]]
.Making an entity persistent with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-persist-native-example]
----
@ -76,7 +76,7 @@ Entities can also be deleted.
[[pc-remove-jpa-example]]
.Deleting an entity with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-remove-jpa-example]
----
@ -85,7 +85,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-remove-jpa-example
[[pc-remove-native-example]]
.Deleting an entity with the Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-remove-native-example]
----
@ -109,7 +109,7 @@ The most common case being the need to create an association between an entity a
[[pc-get-reference-jpa-example]]
.Obtaining an entity reference without initializing its data with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-get-reference-jpa-example]
----
@ -118,7 +118,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-get-reference-jpa-
[[pc-get-reference-native-example]]
.Obtaining an entity reference without initializing its data with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-get-reference-native-example]
----
@ -140,7 +140,7 @@ It is also quite common to want to obtain an entity along with its data (e.g. li
[[pc-find-jpa-example]]
.Obtaining an entity reference with its data initialized with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-jpa-example]
----
@ -150,7 +150,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-jpa-example]
.Obtaining an entity reference with its data initialized with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-native-example]
----
@ -160,7 +160,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-native-exampl
.Obtaining an entity reference with its data initialized using the `byId()` Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-by-id-native-example]
----
@ -174,7 +174,7 @@ It's possible to return a Java 8 `Optional` as well:
.Obtaining an Optional entity reference with its data initialized using the `byId()` Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-optional-by-id-native-example]
----
@ -244,7 +244,7 @@ as illustrated by the following example:
.Loading multiple entities using the `byMultipleIds()` Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/MultiLoadIdTest.java[tags=pc-by-multiple-ids-example]
----
@ -265,7 +265,7 @@ https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/
[[tag::pc-by-multiple-ids-second-level-cache-example]]
.Loading multiple entities from the second-level cache
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/MultiLoadIdTest.java[tags=pc-by-multiple-ids-second-level-cache-example]
----
@ -292,7 +292,7 @@ In addition to allowing to load the entity by its identifier, Hibernate allows a
[[pc-find-by-natural-id-entity-example]]
.Natural-id mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-by-natural-id-entity-example]
----
@ -303,7 +303,7 @@ We can also opt to fetch the entity or just retrieve a reference to it when usin
[[pc-find-by-simple-natural-id-example]]
.Get entity reference by simple natural-id
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-by-simple-natural-id-example]
----
@ -312,7 +312,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-by-simple-nat
[[pc-find-by-natural-id-example]]
.Load entity by natural-id
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-by-natural-id-example]
----
@ -323,7 +323,7 @@ We can also use a Java 8 `Optional` to load an entity by its natural id:
[[pc-find-optional-by-simple-natural-id-example]]
.Load an Optional entity by natural-id
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-find-optional-by-simple-natural-id-example]
----
@ -360,7 +360,7 @@ This can be achieved using the `@SQLRestriction` annotation, which can be applie
[[pc-where-example]]
.`@SQLRestriction` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereTest.java[tags=pc-where-example]
----
@ -371,7 +371,7 @@ If the database contains the following entities:
[[pc-where-persistence-example]]
.Persisting and fetching entities with a `@SQLRestriction` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereTest.java[tags=pc-where-persistence-example]
----
@ -387,7 +387,7 @@ When executing an `Account` entity query, Hibernate is going to filter out all r
[[pc-where-entity-query-example]]
.Query entities mapped with `@SQLRestriction`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereTest.java[tags=pc-where-entity-query-example]
----
@ -403,7 +403,7 @@ When fetching the `debitAccounts` or the `creditAccounts` collections, Hibernate
[[pc-where-collection-query-example]]
.Traversing collections mapped with `@SQLRestriction`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereTest.java[tags=pc-where-collection-query-example]
----
@ -422,7 +422,7 @@ Just like `@SQLRestriction` annotation, `@SQLJoinTableRestriction` is used to fi
[[pc-where-join-table-example]]
.`@SQLJoinTableRestriction` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereJoinTableTest.java[tags=pc-where-join-table-example]
----
@ -441,7 +441,7 @@ Considering that the following two `Book_Reader` entries are added into our syst
[[pc-where-join-table-persist-example]]
.`@SQLJoinTableRestriction` test data
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereJoinTableTest.java[tags=pc-where-join-table-persist-example]
----
@ -452,7 +452,7 @@ When fetching the `currentWeekReaders` collection, Hibernate is going to find on
[[pc-where-join-table-fetch-example]]
.`@SQLJoinTableRestriction` fetch example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/WhereJoinTableTest.java[tags=pc-where-join-table-fetch-example]
----
@ -469,7 +469,7 @@ Now, considering we have the following `Account` entity:
[[pc-filter-account-example]]
.`@Filter` mapping entity-level usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-Account-example]
----
@ -487,7 +487,7 @@ As already explained, we can also apply the `@Filter` annotation for collections
[[pc-filter-client-example]]
.`@Filter` mapping collection-level usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-Client-example]
----
@ -499,7 +499,7 @@ Hibernate will execute the following SQL statements:
[[pc-filter-persistence-example]]
.Persisting and fetching entities with a `@Filter` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-persistence-example]
----
@ -515,7 +515,7 @@ By default, without enabling the filter, Hibernate is going to fetch all `Accoun
[[pc-no-filter-entity-query-example]]
.Query entities mapped without activating the `@Filter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-no-filter-entity-query-example]
----
@ -534,11 +534,11 @@ that it will be enabled by default directly on its `@FilterDef`.
[[pc-filter-entity-query-example]]
.Query entities mapped with `@Filter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-entity-query-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-auto-enabled-Account-example]
----
@ -553,7 +553,7 @@ A parameter's value can be explicitly set on the filter itself, or can be
resolved by using a custom `Supplier`. The resolver must implement
the interface `java.util.function.Supplier` and must be defined as a managed bean.
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-resolver-Account-example]
----
@ -569,7 +569,7 @@ On the other hand, the `minimumAmount` filter is taken into consideration, becau
[[pc-filter-entity-example]]
.Fetching entities mapped with `@Filter`
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-entity-example]
----
@ -600,7 +600,7 @@ either if the filter is enabled explicitly or by setting `autoEnabled` to `true`
[[pc-no-filter-collection-query-example]]
.Traversing collections without activating the `@Filter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-no-filter-collection-query-example]
----
@ -616,7 +616,7 @@ When activating the `@Filter` and fetching the `accounts` collections, Hibernate
[[pc-filter-collection-query-example]]
.Traversing collections mapped with `@Filter`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterTest.java[tags=pc-filter-collection-query-example]
----
@ -654,7 +654,7 @@ if the `@Filter` defines a condition that uses predicates across multiple tables
[[pc-filter-sql-fragment-alias-example]]
.`@SqlFragmentAlias` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterSqlFragementAliasTest.java[tags=pc-filter-sql-fragment-alias-example]
----
@ -666,7 +666,7 @@ Hibernate is going to apply the right table aliases to the filter predicates:
[[pc-filter-sql-fragment-alias-query-example]]
.Fetching a collection filtered with `@SqlFragmentAlias`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterSqlFragementAliasTest.java[tags=pc-filter-sql-fragment-alias-query-example]
----
@ -688,7 +688,7 @@ The `@FilterJoinTable` annotation can be, therefore, applied to a unidirectional
[[pc-filter-join-table-example]]
.`@FilterJoinTable` mapping usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterJoinTableTest.java[tags=pc-filter-join-table-example]
----
@ -703,7 +703,7 @@ Let's assume our database contains the following entities:
[[pc-filter-join-table-persistence-example]]
.Persisting and fetching entities with a `@FilterJoinTable` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterJoinTableTest.java[tags=pc-filter-join-table-persistence-example]
----
@ -719,7 +719,7 @@ The collections can be filtered only if the associated filter is enabled on the
[[pc-no-filter-join-table-collection-query-example]]
.Traversing collections mapped with `@FilterJoinTable` without enabling the filter
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterJoinTableTest.java[tags=pc-no-filter-join-table-collection-query-example]
----
@ -736,7 +736,7 @@ If we enable the filter and set the `maxOrderId` to `1` when fetching the `accou
[[pc-filter-join-table-collection-query-example]]
.Traversing collections mapped with `@FilterJoinTable`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/FilterJoinTableTest.java[tags=pc-filter-join-table-collection-query-example]
----
@ -756,7 +756,7 @@ There is no need to call a particular method to make your modifications persiste
[[pc-managed-state-jpa-example]]
.Modifying managed state with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-managed-state-jpa-example]
----
@ -765,7 +765,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-managed-state-jpa-
[[pc-managed-state-native-example]]
.Modifying managed state with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-managed-state-native-example]
----
@ -778,7 +778,7 @@ Therefore, considering you have the following `Product` entity mapping:
[[pc-managed-state-update-mapping-example]]
.`Product` entity mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/NoDynamicUpdateTest.java[tags=pc-managed-state-update-mapping-example]
----
@ -789,7 +789,7 @@ If you persist the following `Product` entity:
[[pc-managed-state-update-persist-example]]
.Persisting a `Product` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/NoDynamicUpdateTest.java[tags=pc-managed-state-update-persist-example]
----
@ -800,7 +800,7 @@ When you modify the `Product` entity, Hibernate generates the following SQL UPDA
[[pc-managed-state-update-example]]
.Modifying the `Product` entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/NoDynamicUpdateTest.java[tags=pc-managed-state-update-example]
----
@ -829,7 +829,7 @@ To enable dynamic updates, you need to annotate the entity with the `@DynamicUpd
[[pc-managed-state-dynamic-update-mapping-example]]
.`Product` entity mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/DynamicUpdateTest.java[tags=pc-managed-state-dynamic-update-mapping-example]
----
@ -856,7 +856,7 @@ You can reload an entity instance and its collections at any time.
[[pc-refresh-jpa-example]]
.Refreshing entity state with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-refresh-jpa-example]
----
@ -865,7 +865,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-refresh-jpa-exampl
[[pc-refresh-native-example]]
.Refreshing entity state with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-refresh-native-example]
----
@ -910,7 +910,7 @@ For instance, consider the following example:
[[pc-refresh-child-entity-jpa-example]]
.Refreshing entity state gotcha
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-refresh-child-entity-jpa-example]
----
@ -946,7 +946,7 @@ Jakarta Persistence does not support reattaching detached data. This is only ava
[[pc-detach-reattach-lock-example]]
.Reattaching a detached entity using `lock`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-detach-reattach-lock-example]
----
@ -955,7 +955,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-detach-reattach-lo
[[pc-detach-reattach-saveOrUpdate-example]]
.Reattaching a detached entity using `saveOrUpdate`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-detach-reattach-saveOrUpdate-example]
----
@ -981,7 +981,7 @@ Although not exactly per se, the following example is a good visualization of th
[[pc-merge-visualize-example]]
.Visualizing merge
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-merge-visualize-example]
----
@ -990,7 +990,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-merge-visualize-ex
[[pc-merge-jpa-example]]
.Merging a detached entity with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-merge-jpa-example]
----
@ -999,7 +999,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-merge-jpa-example]
[[pc-merge-native-example]]
.Merging a detached entity with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-merge-native-example]
----
@ -1072,7 +1072,7 @@ An application can verify the state of entities and collections in relation to t
[[pc-contains-jpa-example]]
.Verifying managed state with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-contains-jpa-example]
----
@ -1081,7 +1081,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-contains-jpa-examp
[[pc-contains-native-example]]
.Verifying managed state with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-contains-native-example]
----
@ -1090,7 +1090,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-contains-native-ex
[[pc-verify-lazy-jpa-example]]
.Verifying laziness with Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-verify-lazy-jpa-example]
----
@ -1099,7 +1099,7 @@ include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-verify-lazy-jpa-ex
[[pc-verify-lazy-native-example]]
.Verifying laziness with Hibernate API
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-verify-lazy-native-example]
----
@ -1110,7 +1110,7 @@ In Jakarta Persistence there is an alternative means to check laziness using the
[[pc-verify-lazy-jpa-alternative-example]]
.Alternative Jakarta Persistence means to verify laziness
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/PersistenceContextTest.java[tags=pc-verify-lazy-jpa-alternative-example]
----
@ -1125,7 +1125,7 @@ the `evict()` method can be used to remove the object and its collections from t
[[caching-management-jpa-detach-example]]
.Detaching an entity from the `EntityManager`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/FirstLevelCacheTest.java[tags=caching-management-jpa-detach-example]
----
@ -1134,7 +1134,7 @@ include::{example-dir-caching}/FirstLevelCacheTest.java[tags=caching-management-
[[caching-management-native-evict-example]]
.Evicting an entity from the Hibernate `Session`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/FirstLevelCacheTest.java[tags=caching-management-native-evict-example]
----
@ -1145,7 +1145,7 @@ To detach all entities from the current persistence context, both the `EntityMan
[[caching-management-clear-example]]
.Clearing the persistence context
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/FirstLevelCacheTest.java[tags=caching-management-clear-example]
----
@ -1156,7 +1156,7 @@ To verify if an entity instance is currently attached to the running persistence
[[caching-management-contains-example]]
.Verify if an entity is contained in a persistence context
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-caching}/FirstLevelCacheTest.java[tags=caching-management-contains-example]
----
@ -1183,7 +1183,7 @@ Additionally, the `CascadeType.ALL` will propagate any Hibernate-specific operat
The following examples will explain some of the aforementioned cascade operations using the following entities:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/Person.java[tags=pc-cascade-domain-model-example]
@ -1198,7 +1198,7 @@ The `CascadeType.PERSIST` allows us to persist a child entity along with the par
[[pc-cascade-persist-example]]
.`CascadeType.PERSIST` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadePersistTest.java[tags=pc-cascade-persist-example]
----
@ -1219,7 +1219,7 @@ The `CascadeType.MERGE` allows us to merge a child entity along with the parent
[[pc-cascade-merge-example]]
.`CascadeType.MERGE` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeMergeTest.java[tags=pc-cascade-merge-example]
----
@ -1243,7 +1243,7 @@ However, `CascadeType.REMOVE` and `org.hibernate.annotations.CascadeType.DELETE`
[[pc-cascade-remove-example]]
.`CascadeType.REMOVE` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeRemoveTest.java[tags=pc-cascade-remove-example]
----
@ -1262,7 +1262,7 @@ include::{extrasdir}/pc-cascade-remove-example.sql[]
[[pc-cascade-detach-example]]
.`CascadeType.DETACH` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeDetachTest.java[tags=pc-cascade-detach-example]
----
@ -1279,7 +1279,7 @@ However, `CascadeType.LOCK` allows us to reattach a parent entity along with its
[[pc-cascade-lock-example]]
.`CascadeType.LOCK` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeLockTest.java[tags=pc-cascade-lock-example]
----
@ -1294,7 +1294,7 @@ The refresh operation will discard the current entity state, and it will overrid
[[pc-cascade-refresh-example]]
.`CascadeType.REFRESH` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeRefreshTest.java[tags=pc-cascade-refresh-example]
----
@ -1316,7 +1316,7 @@ The replicate operation allows you to synchronize entities coming from different
[[pc-cascade-replicate-example]]
.`CascadeType.REPLICATE` example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeReplicateTest.java[tags=pc-cascade-replicate-example]
----
@ -1342,12 +1342,12 @@ as illustrated by the following example.
[[pc-cascade-on-delete-mapping-example]]
.`@OnDelete` `@ManyToOne` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-mapping-Person-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-mapping-Phone-example]
----
@ -1363,7 +1363,7 @@ Now, you can just remove the `Person` entity, and the associated `Phone` entitie
[[pc-cascade-on-delete-example]]
.`@OnDelete` `@ManyToOne` delete example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-example]
----
@ -1380,12 +1380,12 @@ illustrated in the following example.
[[pc-cascade-on-delete-collection-mapping-example]]
.`@OnDelete` `@OneToMany` mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteCollectionTest.java[tags=pc-cascade-on-delete-collection-mapping-Person-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteCollectionTest.java[tags=pc-cascade-on-delete-collection-mapping-Phone-example]
----
@ -1396,7 +1396,7 @@ Now, when removing the `Person` entity, all the associated `Phone` child entitie
[[pc-cascade-on-delete-collection-example]]
.`@OnDelete` `@ManyToOne` delete example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-pc}/CascadeOnDeleteCollectionTest.java[tags=pc-cascade-on-delete-collection-example]
----

View File

@ -49,7 +49,7 @@ The application wants to select entity instances.
[[criteria-typedquery-entity-example]]
.Selecting the root entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-typedquery-entity-example]
----
@ -77,7 +77,7 @@ But this expression might also represent an aggregation, a mathematical operatio
[[criteria-typedquery-expression-example]]
.Selecting an attribute
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-typedquery-expression-example]
----
@ -97,7 +97,7 @@ or consider a wrapper query, see <<criteria-typedquery-wrapper>> for details.
[[criteria-typedquery-multiselect-array-explicit-example]]
.Selecting an array
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-typedquery-multiselect-array-explicit-example]
----
@ -111,7 +111,7 @@ The example then uses the array method of `jakarta.persistence.criteria.Criteria
[[criteria-typedquery-multiselect-array-implicit-example]]
.Selecting an array using `multiselect`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-typedquery-multiselect-array-implicit-example]
----
@ -131,7 +131,7 @@ Going back to the example query there, rather than returning an array of _[Perso
[[criteria-typedquery-wrapper-example]]
.Selecting a wrapper
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/PersonWrapper.java[tags=criteria-typedquery-wrapper-example, indent=0]
@ -155,7 +155,7 @@ A better approach to <<criteria-typedquery-multiselect>> is to use either a wrap
[[criteria-tuple-example]]
.Selecting a tuple
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-tuple-example]
----
@ -207,7 +207,7 @@ A root is always an entity type. Roots are defined and added to the criteria by
[[criteria-from-root-methods-example]]
.Root methods
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
<X> Root<X> from( Class<X> );
@ -218,7 +218,7 @@ A root is always an entity type. Roots are defined and added to the criteria by
[[criteria-from-root-example]]
.Adding a root example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-from-root-example]
----
@ -230,7 +230,7 @@ Here is an example defining a Cartesian Product between `Person` and `Partner` e
[[criteria-from-multiple-root-example]]
.Adding multiple roots example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-from-multiple-root-example]
----
@ -245,7 +245,7 @@ Joins are created by the numerous overloaded __join__ methods of the `jakarta.pe
[[criteria-from-join-example]]
.Join example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-from-join-example]
----
@ -260,7 +260,7 @@ Fetches are created by the numerous overloaded __fetch__ methods of the `jakarta
[[criteria-from-fetch-example]]
.Join fetch example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-from-fetch-example]
----
@ -286,7 +286,7 @@ Roots, joins and fetches are themselves path expressions as well.
[[criteria-param-example]]
.Parameters example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-param-example]
----
@ -301,7 +301,7 @@ Then use the parameter reference to bind the parameter value to the `jakarta.per
[[criteria-group-by-example]]
.Group by example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CriteriaTest.java[tags=criteria-group-by-example]
----

View File

@ -24,7 +24,7 @@ This can be done by using the `JpaCriteriaQuery#createCountQuery()` method.
[[criteria-extensions-count-query-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-criteria}/CountQueryTests.java[tags=criteria-extensions-count-query-example]
----

View File

@ -55,7 +55,7 @@ As Oracle AI Vector Search supports different types of elements (to ensure bette
[[vector-module-usage-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=usage-example]
----
@ -111,7 +111,7 @@ which is `1 - inner_product( v1, v2 ) / ( vector_norm( v1 ) * vector_norm( v2 )
[[vector-module-functions-cosine-distance-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=cosine-distance-example]
----
@ -126,7 +126,7 @@ The `l2_distance()` function is an alias.
[[vector-module-functions-euclidean-distance-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=euclidean-distance-example]
----
@ -141,7 +141,7 @@ The `l1_distance()` function is an alias.
[[vector-module-functions-taxicab-distance-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=taxicab-distance-example]
----
@ -156,7 +156,7 @@ and the `inner_product()` function as well, but multiplies the result time `-1`.
[[vector-module-functions-inner-product-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=inner-product-example]
----
@ -169,7 +169,7 @@ Determines the dimensions of a vector.
[[vector-module-functions-vector-dims-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=vector-dims-example]
----
@ -183,7 +183,7 @@ which is `sqrt( sum( v_i^2 ) )`.
[[vector-module-functions-vector-norm-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-vector}/PGVectorTest.java[tags=vector-norm-example]
----

View File

@ -38,7 +38,7 @@ The code examples featured in this chapter, and the next, make use of the follow
[[hql-examples-domain-model-example]]
.Examples domain model
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=hql-examples-domain-model-example]
@ -80,7 +80,7 @@ Named queries may be defined using the Jakarta Persistence annotation `@NamedQue
[[jpa-read-only-entities-native-example]]
.Declaring a named query with a query hint
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=jpa-read-only-entities-native-example]
----
@ -93,7 +93,7 @@ which allows the specification of additional properties of the query, including
[[jpql-api-hibernate-named-query-example]]
.Declaring a named query using the typesafe annotation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Phone.java[tags=jpql-api-hibernate-named-query-example, indent=0]
----
@ -127,7 +127,7 @@ That way, you'll obtain a `TypedQuery<T>`, and avoid some later typecasting.
[[jpql-api-example]]
.Obtaining a Jakarta Persistence `Query` or `TypedQuery` reference
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-example]
----
@ -136,7 +136,7 @@ include::{example-dir-query}/HQLTest.java[tags=jpql-api-example]
[[jpql-api-named-query-example]]
.Obtaining a Jakarta Persistence `Query` or `TypedQuery` reference for a named query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=jpql-api-named-query-example, indent=0]
@ -162,7 +162,7 @@ Hibernate's `Query` interface offers additional operations not available via `Ty
[[hql-api-example]]
.Obtaining a Hibernate `Query`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-example]
----
@ -171,7 +171,7 @@ include::{example-dir-query}/HQLTest.java[tags=hql-api-example]
[[hql-api-named-query-example]]
.Obtaining a Hibernate `Query` for a named query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-named-query-example]
----
@ -195,7 +195,7 @@ If the query has parameters, arguments must be bound to each parameter before th
[[jpql-api-parameter-example]]
.Named parameter binding
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-parameter-example]
----
@ -207,7 +207,7 @@ Just like with named parameters, a ordinal parameter may appear multiple times i
[[jpql-api-ordinal-parameter-example]]
.Ordinal parameter binding
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-ordinal-parameter-example]
----
@ -231,7 +231,7 @@ The `Query` interface is used to control the execution of the query.
[[jpql-api-list-example]]
.Executing a query using `getResultList()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-list-example]
----
@ -240,7 +240,7 @@ include::{example-dir-query}/HQLTest.java[tags=jpql-api-list-example]
[[jpql-api-unique-result-example]]
.Executing a query using `getSingleResult()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-single-result-example]
----
@ -249,7 +249,7 @@ include::{example-dir-query}/HQLTest.java[tags=jpql-api-single-result-example]
[[jpql-api-stream-example]]
.Executing a query using `getResultStream()`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-stream-example]
----
@ -269,7 +269,7 @@ The very important methods `Query#setMaxResults()` and `Query#setFirstResult()`
[[jpql-api-basic-usage-example]]
.Limits and pagination
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-basic-usage-example]
----
@ -284,7 +284,7 @@ For example, we may want to specify an execution timeout or control caching.
[[jpql-api-hint-usage-example]]
.`Query` execution using a query hint
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=jpql-api-hint-usage-example]
----
@ -353,7 +353,7 @@ For complete details, see the https://docs.jboss.org/hibernate/orm/{majorMinorVe
[[hql-api-basic-usage-example]]
.Advanced query control
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-basic-usage-example]
----
@ -376,7 +376,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//[[hql-api-parameter-example]]
//.Hibernate name parameter binding
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-parameter-example]
//----
@ -388,7 +388,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//[[hql-api-parameter-inferred-type-example]]
//.Hibernate name parameter binding (inferred type)
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-parameter-inferred-type-example]
//----
@ -399,7 +399,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//[[hql-api-parameter-short-form-example]]
//.Hibernate name parameter binding (short forms)
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-parameter-short-form-example]
//----
@ -411,7 +411,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//
//There was no way to relate two such ordinal parameters as being "the same" aside from binding the same value to each and, for this reason, this form is no longer supported.
//
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-ordinal-parameter-example]
//----
@ -425,7 +425,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//[[hql-api-list-example]]
//.Hibernate `list()` result
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-list-example]
//----
@ -436,7 +436,7 @@ See the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hi
//[[hql-api-unique-result-example]]
//.Hibernate `uniqueResult()`
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-api-unique-result-example]
//----
@ -460,7 +460,7 @@ Read-only entities are skipped by the dirty checking mechanism as illustrated by
[[hql-read-only-entities-example]]
.Read-only entities query example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-read-only-entities-example]
----
@ -478,7 +478,7 @@ The method `Query#setReadOnly()` is an alternative to using a Jakarta Persistenc
[[hql-read-only-entities-native-example]]
.Read-only entities native query example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-read-only-entities-native-example]
----
@ -498,7 +498,7 @@ Depending on the specified `ScrollMode`, and on the capabilities of the JDBC dri
[[hql-api-scroll-example]]
.Scrolling through a `ResultSet` containing entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-scroll-example]
----
@ -531,7 +531,7 @@ For that, use `getResultList().stream()`.
[[hql-api-stream-projection-example]]
.Hibernate `getResultStream()` with a projection result type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-stream-projection-example]
----
@ -540,7 +540,7 @@ include::{example-dir-query}/HQLTest.java[tags=hql-api-stream-projection-example
[[hql-api-stream-example]]
.Hibernate `getResultStream()` with an entity result type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/HQLTest.java[tags=hql-api-stream-example]
----
@ -583,7 +583,7 @@ it does not expose a `#executeUpdate` method. This allows for earlier validatio
[[hql-examples-selection-query]]
.Selection query validation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/SelectionQueryExampleTests.java[tags=example-hql-selection-query]
@ -596,7 +596,7 @@ include::{example-dir-query}/SelectionQueryExampleTests.java[tags=example-hql-se
[[hql-examples-named-selection-query]]
.NamedQuery selection validation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/SelectionQueryExampleTests.java[tags=example-hql-named-selection-query]
@ -616,7 +616,7 @@ For example, in terms of execution, it only exposes `#executeUpdate` method. Th
[[hql-examples-mutation-query]]
.Mutation query validation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/MutationQueryExampleTests.java[tags=example-hql-mutation-query]
@ -630,7 +630,7 @@ include::{example-dir-query}/MutationQueryExampleTests.java[tags=example-hql-mut
[[hql-examples-named-mutation-query]]
.NamedQuery mutation validation
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-query}/MutationQueryExampleTests.java[tags=example-hql-named-mutation-query]

View File

@ -109,7 +109,7 @@ For example, the simplest query in HQL has no `select` clause at all:
[[hql-select-simplest-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-simplest-example]
----
@ -123,14 +123,14 @@ HQL doesn't require a `select` clause, but JPQL _does_.
Naturally, the previous query may be written with a `select` clause:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-simplest-jpql-example]
----
When there's no explicit `select` clause, the select list is implied by the result type of the query:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-no-from]
----
@ -157,7 +157,7 @@ Looking carefully at the BNF given above, you might notice that the `select` lis
Of course, standard SQL, and JPQL, require that the `select` list comes at the beginning.
But it's more natural to put it last:
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-last-example]
----
@ -184,7 +184,7 @@ For example:
[[hql-update-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-update-example]
----
@ -196,7 +196,7 @@ A single HQL `update` statement might result in multiple SQL update statements e
[[hql-update-examples]]
//.Example update queries
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-jpql-update-example]
@ -224,7 +224,7 @@ Adding the keyword `versioned`&mdash;writing `update versioned`&mdash;specifies
[[hql-update-versioned-example]]
//.Example update queries
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-hql-update-version-example]
----
@ -239,7 +239,7 @@ it is undefined which row is updated or whether an error is thrown.
[[hql-update-join-example]]
//.Example update join queries
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/../query/hql/UpdateJoinTests.java[tags=hql-update-join-example]
----
@ -275,7 +275,7 @@ A `delete` statement may use implicit or explicit joins.
[[hql-delete-join-example]]
//.Example delete join queries
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/../query/hql/DeleteJoinTests.java[tags=hql-delete-join-example]
----
@ -421,7 +421,7 @@ To escape a single quote within a string literal, use a doubled single quote: `'
[[hql-string-literals-example]]
//.String literals examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-string-literals-example]
----
@ -435,7 +435,7 @@ Numeric literals come in several different forms.
[[hql-numeric-literals-example]]
//.Numeric literal examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-numeric-literals-example]
----
@ -536,7 +536,7 @@ Literal values of a Java enumerated type may be written without needing to speci
[[hql-enum-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-enum-example]
----
@ -551,7 +551,7 @@ HQL allows any Java `static` constant to be used in HQL, but it must be referenc
[[hql-java-constant-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-java-constant-example]
----
@ -580,7 +580,7 @@ See <<hql-string-functions, below>> for details of the `concat()` function.
[[hql-concatenation-example]]
//.Concatenation operation example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-concatenation-example]
----
@ -596,7 +596,7 @@ The basic SQL arithmetic operators, `+`,`-`,`*`, and `/` are joined by the remai
[[hql-numeric-arithmetic-example]]
//.Numeric arithmetic examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-numeric-arithmetic-example]
----
@ -679,7 +679,7 @@ For example:
[[hql-simple-case-expressions-example]]
//.Simple case expression example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-simple-case-expressions-example]
----
@ -701,7 +701,7 @@ For example:
[[hql-searched-case-expressions-example]]
//.Searched case expression example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-searched-case-expressions-example]
----
@ -712,7 +712,7 @@ A `case` expression may contain complex expression, including operator expressio
[[hql-case-arithmetic-expressions-example]]
//.Case expression with arithmetic operation example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-case-arithmetic-expressions-example]
----
@ -767,7 +767,7 @@ This is mainly useful when dealing with entity inheritance hierarchies.
[[hql-entity-type-exp-example]]
//.Entity type expression examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-entity-type-exp-example]
----
@ -781,7 +781,7 @@ This is useful when dealing with entity or embeddable inheritance hierarchies.
[[hql-treat-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-treat-example]
----
@ -802,7 +802,7 @@ The target type is an unqualified Java class name:
`String`, `Long`, `Integer`, `Double`, `Float`, `Character`, `Byte`, `BigInteger`, `BigDecimal`, `LocalDate`, `LocalTime`, `LocalDateTime`, etc.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-cast-function-example]
----
@ -814,7 +814,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-cast-function-example]
The function `str(x)` is a synonym for `cast(x as String)`.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-str-function-example]
----
@ -839,7 +839,7 @@ An abbreviated `case` expression that returns the first non-null operand.
[[hql-coalesce-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-coalesce-example]
----
@ -855,7 +855,7 @@ Evaluates to null if its operands are equal, or to its first argument otherwise.
[[hql-nullif-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-nullif-example]
----
@ -883,7 +883,7 @@ Field types include: `day`, `month`, `year`, `second`, `minute`, `hour`, `day of
For a full list of field types, see the Javadoc for https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/query/TemporalUnit.html[`TemporalUnit`].
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-extract-function-example]
----
@ -905,7 +905,7 @@ The following functions are abbreviations for `extract()`:
TIP: These abbreviations aren't part of the JPQL standard, but on the other hand they're a lot less verbose.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-year-function-example]
----
@ -968,7 +968,7 @@ IMPORTANT: Contrary to Java, positions of characters within strings are indexed
Accepts a variable number of arguments, and produces a string by concatenating them.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-concat-function-example]
----
@ -980,7 +980,7 @@ The JPQL function `locate()` determines the position of a substring within anoth
- The optional third argument is used to specify a position at which to start the search.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-locate-function-example]
----
@ -991,7 +991,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-locate-function-example]
The `position()` function has a similar purpose, but follows the ANSI SQL syntax.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-position-function-example]
----
@ -1004,7 +1004,7 @@ Returns a substring of the given string.
- The optional third argument specifies the maximum length of the substring.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-substring-function-example]
----
@ -1015,7 +1015,7 @@ The `trim()` function follows the syntax and semantics of ANSI SQL.
It may be used to trim `leading` characters, `trailing` characters, or both.
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-trim-function-example]
----
@ -1034,15 +1034,15 @@ trimSpecification
====
//====
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-length-function-example]
//----
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-upper-function-example]
//----
//[source, JAVA, indent=0]
//[source, java, indent=0]
//----
//include::{sourcedir}/HQLTest.java[tags=hql-lower-function-example]
//----
@ -1091,15 +1091,15 @@ Of course, we also have a number of functions for working with numeric values.
|===
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-abs-function-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-mod-function-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-sqrt-function-example]
----
@ -1133,7 +1133,7 @@ The number of elements of a collection or to-many association.
[[hql-size-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-size-example]
----
@ -1215,7 +1215,7 @@ To retrieve the result as `List<?>`, use the `array_list()` function.
[[hql-array-constructor-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayConstructorTest.java[tags=hql-array-example]
----
@ -1226,7 +1226,7 @@ which is syntax sugar that translates to the array constructor function.
[[hql-array-constructor-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayConstructorTest.java[tags=hql-array-hql-example]
----
@ -1239,7 +1239,7 @@ An <<hql-aggregate-functions-orderedset,ordered set aggregate function>> that ag
[[hql-array-agg-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayAggregateTest.java[tags=hql-array-agg-example]
----
@ -1252,7 +1252,7 @@ Returns the 1-based position of an element in the array. Returns 0 if the elemen
[[hql-array-position-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayPositionTest.java[tags=hql-array-position-example]
----
@ -1263,7 +1263,7 @@ which is overloaded to also accept an array argument.
[[hql-array-position-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayPositionTest.java[tags=hql-array-position-hql-example]
----
@ -1277,7 +1277,7 @@ To retrieve the result as `List<Integer>`, use the `array_positions_list()` func
[[hql-array-positions-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayPositionsTest.java[tags=hql-array-positions-example]
----
@ -1290,7 +1290,7 @@ Returns size of the passed array. Returns `null` if the array is `null`.
[[hql-array-length-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayLengthTest.java[tags=hql-array-length-example]
----
@ -1301,7 +1301,7 @@ which is overloaded to also accept an array argument.
[[hql-array-length-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayLengthTest.java[tags=hql-array-length-hql-example]
----
@ -1314,7 +1314,7 @@ Concatenates arrays with each other in order. Returns `null` if one of the argum
[[hql-array-concat-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayConcatTest.java[tags=hql-array-concat-example]
----
@ -1324,7 +1324,7 @@ Arrays can also be concatenated with the `||` (double-pipe) operator.
[[hql-array-concat-pipe-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayConcatTest.java[tags=hql-array-concat-pipe-example]
----
@ -1334,7 +1334,7 @@ In addition, the `||` (double-pipe) operator also support concatenating single e
[[hql-array-concat-pipe-element-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayConcatTest.java[tags=hql-array-concat-pipe-element-example]
----
@ -1347,7 +1347,7 @@ Prepends element to array. Returns `null` if the array argument is `null`.
[[hql-array-prepend-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayPrependTest.java[tags=hql-array-prepend-example]
----
@ -1360,7 +1360,7 @@ Appends element to array. Returns `null` if the array argument is `null`.
[[hql-array-append-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayAppendTest.java[tags=hql-array-append-example]
----
@ -1375,7 +1375,7 @@ is undefined when the second argument, the element to search, is `null`.
[[hql-array-contains-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayContainsTest.java[tags=hql-array-contains-example]
----
@ -1387,7 +1387,7 @@ This is syntax sugar that translates to the `array_contains` function.
[[hql-array-contains-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayContainsTest.java[tags=hql-array-contains-hql-example]
----
@ -1403,7 +1403,7 @@ is undefined when the second argument contains a `null`.
[[hql-array-contains-array-example]]
[[hql-array-includes-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIncludesTest.java[tags=hql-array-includes-example]
----
@ -1414,7 +1414,7 @@ To search for `null` elements, the `array_includes_nullable` function must be us
[[hql-array-contains-array-nullable-example]]
[[hql-array-includes-nullable-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIncludesTest.java[tags=hql-array-includes-nullable-example]
----
@ -1426,7 +1426,7 @@ This is syntax sugar that translates to the `array_includes` function.
[[hql-array-includes-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIncludesTest.java[tags=hql-array-includes-hql-example]
----
@ -1444,7 +1444,7 @@ Only `array_intersects_nullable` is guaranteed to produce correct results for `n
[[hql-array-overlaps-example]]
[[hql-array-intersects-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIntersectsTest.java[tags=hql-array-intersects-example]
----
@ -1453,7 +1453,7 @@ include::{array-example-dir-hql}/ArrayIntersectsTest.java[tags=hql-array-interse
[[hql-array-overlaps-nullable-example]]
[[hql-array-intersects-nullable-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIntersectsTest.java[tags=hql-array-intersects-nullable-example]
----
@ -1465,7 +1465,7 @@ This is syntax sugar that translates to the `array_intersects` function.
[[hql-array-overlaps-hql-example]]
[[hql-array-intersects-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayIntersectsTest.java[tags=hql-array-intersects-hql-example]
----
@ -1479,7 +1479,7 @@ and also if the index is bigger than the array length.
[[hql-array-get-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayGetTest.java[tags=hql-array-get-example]
----
@ -1492,7 +1492,7 @@ Returns an array copy with the given element placed at the given 1-based index,
[[hql-array-set-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArraySetTest.java[tags=hql-array-set-example]
----
@ -1505,7 +1505,7 @@ Returns an array copy with the given element removed from the array. Allows remo
[[hql-array-remove-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayRemoveTest.java[tags=hql-array-remove-example]
----
@ -1518,7 +1518,7 @@ Returns an array copy with the element at the given index removed from the array
[[hql-array-remove-index-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayRemoveIndexTest.java[tags=hql-array-remove-index-example]
----
@ -1532,7 +1532,7 @@ and also if the index is out of bounds.
[[hql-array-slice-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArraySliceTest.java[tags=hql-array-slice-example]
----
@ -1544,7 +1544,7 @@ This is syntax sugar that translates to the `array_slice` function.
[[hql-array-slice-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArraySliceTest.java[tags=hql-array-slice-hql-example]
----
@ -1557,7 +1557,7 @@ Returns an array copy which has elements matching the second argument replaced b
[[hql-array-replace-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayReplaceTest.java[tags=hql-array-replace-example]
----
@ -1571,7 +1571,7 @@ It is an error if any array has a length smaller than the second argument.
[[hql-array-trim-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayTrimTest.java[tags=hql-array-trim-example]
----
@ -1586,7 +1586,7 @@ To retrieve the result as `List<?>`, use the `array_fill_list()` function.
[[hql-array-fill-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayFillTest.java[tags=hql-array-fill-example]
----
@ -1602,7 +1602,7 @@ Returns `null` if the first argument is `null`.
[[hql-array-to-string-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayToStringTest.java[tags=hql-array-to-string-example]
----
@ -1613,7 +1613,7 @@ which is a short version of `concat('[', array_to_string(array, ',', 'null'), ']
[[hql-array-to-string-hql-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{array-example-dir-hql}/ArrayToStringTest.java[tags=hql-array-to-string-hql-example]
----
@ -1649,7 +1649,7 @@ Then at startup Hibernate will log a list of type signatures of all registered f
[[hql-var-function-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-native-function-example]
----
@ -1695,7 +1695,7 @@ The operands should be of the same type.
[[hql-relational-comparisons-example]]
//.Relational comparison examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-relational-comparisons-example]
----
@ -1711,7 +1711,7 @@ Of course, all three operands must be of compatible type.
[[hql-between-predicate-example]]
//.Between examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-between-predicate-example]
----
@ -1732,7 +1732,7 @@ The following operators make it easier to deal with null values.
[[hql-null-predicate-example]]
//.Nullness checking examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-null-predicate-example]
----
@ -1782,7 +1782,7 @@ The expression on the right is a pattern, where:
[[hql-like-predicate-example]]
//.Like predicate examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-like-predicate-example]
----
@ -1795,7 +1795,7 @@ For example, to match all stored procedures prefixed with `Dr_`, the like criter
[[hql-like-predicate-escape-example]]
//.Like with escape symbol
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-like-predicate-escape-example]
----
@ -1863,7 +1863,7 @@ Even embedded attributes are allowed, although that feature depends on the level
[[hql-in-predicate-example]]
//.In predicate examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-in-predicate-example]
----
@ -1872,7 +1872,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-in-predicate-example]
[[hql-collection-expressions-in-example]]
//.In indices example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-expressions-in-example]
----
@ -1926,7 +1926,7 @@ The qualifiers are unary prefix operators: `all`, `every`, `any`, and `some`.
[[hql-all-subquery-comparison-qualifier-example]]
//.Subquery comparison example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-all-subquery-comparison-qualifier-example]
----
@ -1935,12 +1935,12 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-all-subquery-comparison-qualifi
[[hql-collection-expressions-all-some-example]]
//.All elements and some elements
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-expressions-all-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-expressions-some-example]
----
@ -1961,7 +1961,7 @@ As you can surely guess, `not exists` evaluates to true if the thing to the righ
[[hql-collection-expressions-exists-example]]
//.Exists elements example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-expressions-exists-example]
----
@ -1982,7 +1982,7 @@ The following operators apply to collection-valued attributes and to-many associ
[[hql-empty-collection-predicate-example]]
//.Empty collection expression examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-empty-collection-predicate-example]
----
@ -1991,7 +1991,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-empty-collection-predicate-exam
[[hql-member-of-collection-predicate-example]]
//.Member-of collection expression examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-member-of-collection-predicate-example]
----
@ -2037,7 +2037,7 @@ Remember, the _entity name_ is the value of the `name` member of the `@Entity` a
[[hql-root-reference-jpql-example]]
//.Entity name for root entity reference
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-simplest-jpql-example]
----
@ -2051,7 +2051,7 @@ Then Hibernate will query every entity which inherits the named type.
[[hql-root-reference-jpql-fqn-example]]
//.Class name for root entity reference
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-simplest-jpql-fqn-example]
----
@ -2067,7 +2067,7 @@ Of course, there may be multiple root entities.
include::{example-dir-hql}/HQLTest.java[tags=hql-multiple-root-reference-jpql-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-multiple-same-root-reference-jpql-example]
----
@ -2092,7 +2092,7 @@ Consider:
[[hql-polymorphism-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-polymorphism-example, indent=0]
----
@ -2118,7 +2118,7 @@ It must declare an identification variable.
[[hql-derived-root-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-derived-root-example, indent=0]
----
@ -2207,7 +2207,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-explicit-inner-join-example]
[[hql-explicit-outer-join-example]]
//.Explicit left (outer) join examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-explicit-outer-join-example]
----
@ -2234,7 +2234,7 @@ Join conditions occurring in the `with` or `on` clause are added to the `on` cla
[[hql-explicit-join-with-example]]
//.HQL `with` clause join example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-explicit-join-with-example]
----
@ -2245,7 +2245,7 @@ The following query is arguably less clear, but semantically equivalent:
[[hql-explicit-join-jpql-on-example]]
//.JPQL `on` clause join example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-explicit-join-jpql-on-example]
----
@ -2272,7 +2272,7 @@ For example, if `Person` has a one-to-many association named `phones`, the use o
[[hql-explicit-fetch-join-example]]
//.Fetch join example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-explicit-fetch-join-example]
----
@ -2309,7 +2309,7 @@ An explicit join may narrow the type of the joined entity using `treat()`.
[[hql-join-treat-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-join-treat-example]
----
@ -2332,7 +2332,7 @@ The `lateral` keyword just distinguishes the two cases.
[[hql-derived-join-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-derived-join-example, indent=0]
----
@ -2379,7 +2379,7 @@ In the second case, Hibernate with automatically add a join to the generated SQL
[[hql-implicit-join-example]]
//.Simple implicit join example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-implicit-join-example]
----
@ -2396,7 +2396,7 @@ Note that:
[[hql-implicit-join-alias-example]]
//.Reused implicit join
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-implicit-join-alias-example]
----
@ -2414,7 +2414,7 @@ When a join involves a collection or many-valued association, the declared ident
[[hql-collection-valued-associations-example]]
//.Collection references example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-valued-associations]
----
@ -2443,7 +2443,7 @@ In particular, `index()` and `key()` obtain a reference to a list index or map k
[[hql-collection-qualification-example]]
//.Qualified collection references example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Phone.java[tags=hql-collection-qualification-example, indent=0]
@ -2458,7 +2458,7 @@ The functions `element()`, `index()`, `key()`, and `value()` may even be applied
[[hql-collection-implicit-join-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-implicit-join-example, indent=0]
----
@ -2469,7 +2469,7 @@ An element of an indexed collection (an array, list, or map) may even be identif
[[hql-collection-index-operator-example]]
//.Index operator examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-index-operator-example]
----
@ -2502,7 +2502,7 @@ But if there are multiple expressions in the select list then:
[[hql-select-clause-projection-example]]
//.Query results as lists
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=jpql-projection-example]
----
@ -2538,7 +2538,7 @@ The `select new` construct packages the query results into a user-written Java c
[[hql-select-clause-dynamic-instantiation-example]]
//.Query results via `select new`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/CallStatistics.java[tags=hql-select-clause-dynamic-instantiation-example]
@ -2560,7 +2560,7 @@ Alternatively, using the syntax `select new map`, the query may specify that eac
[[hql-select-clause-dynamic-map-instantiation-example]]
//.Query results as maps
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-clause-dynamic-map-instantiation-example]
----
@ -2574,7 +2574,7 @@ Or, using the syntax `select new list`, the query may specify that each result s
[[hql-select-clause-dynamic-list-instantiation-example]]
//.Query results as lists
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-select-clause-dynamic-list-instantiation-example]
----
@ -2596,7 +2596,7 @@ It's only effect is to add `distinct` to the generated SQL.
[[hql-distinct-projection-query-example]]
//.Using `distinct` to remove duplicate rows
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/SelectDistinctTest.java[tags=hql-distinct-projection-query-example]
----
@ -2643,7 +2643,7 @@ There are also <<hql-aggregate-functions-orderedset,ordered set aggregate functi
[[hql-aggregate-functions-example]]
//.Aggregate function examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-aggregate-functions-example]
----
@ -2681,7 +2681,7 @@ The `elements()` and `indices()` functions we met <<hql-elements-indices,earlier
[[hql-collection-expressions-example]]
//.Collection-related expressions examples
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-collection-expressions-example]
----
@ -2700,12 +2700,12 @@ All aggregate functions support the inclusion of a _filter clause_, a sort of mi
[[hql-aggregate-functions-filter-example]]
//.Using filter with aggregate functions
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-aggregate-functions-simple-filter-example]
----
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-aggregate-functions-filter-example]
----
@ -2739,7 +2739,7 @@ This function has different names on different databases, but HQL abstracts thes
[[hql-aggregate-functions-within-group-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-aggregate-functions-within-group-example]
----
@ -2846,7 +2846,7 @@ Consider the following queries:
[[hql-group-by-example]]
//.Group by example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-group-by-example]
----
@ -2878,7 +2878,7 @@ If that ended up being too much data to deal with, we might want to restrict the
[[hql-group-by-having-example]]
//.Having example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-group-by-having-example]
----
@ -2900,7 +2900,7 @@ Just like in SQL, `all` suppresses the elimination of duplicate results.
[[hql-union-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-union-example]
----
@ -2965,7 +2965,7 @@ Therefore, the sorting of null values may also be explicitly specified:
[[hql-order-by-example]]
//.Order by example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-order-by-example]
----
@ -3002,7 +3002,7 @@ These two queries are identical:
[[hql-limit-example]]
//.Order by example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-limit-example]
----
@ -3023,7 +3023,7 @@ This next query is accepted by HQL, and no more than 50 results are returned by
[[hql-bad-limit-example]]
//.Order by example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-bad-limit-example]
----
@ -3084,7 +3084,7 @@ whereas `NOT MATERIALIZED` will cause the subquery to be inlined into every use
[[hql-cte-materialized-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-cte-materialized-example, indent=0]
----
@ -3103,7 +3103,7 @@ Recursive CTEs must follow a very particular shape, which is
[[hql-cte-recursive-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-cte-recursive-example, indent=0]
----
@ -3149,7 +3149,7 @@ A DBMS has two possible orders when executing the recursive query part
[[hql-cte-recursive-search-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-cte-recursive-search-example, indent=0]
----
@ -3177,7 +3177,7 @@ cycleClause
[[hql-cte-recursive-cycle-example]]
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-hql}/HQLTest.java[tags=hql-cte-recursive-cycle-example, indent=0]
----

View File

@ -26,7 +26,7 @@ The most basic SQL query is to get a list of scalars (column) values.
[[sql-jpa-all-columns-scalar-query-example]]
.Jakarta Persistence native query selecting all columns
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-all-columns-scalar-query-example]
----
@ -35,7 +35,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-all-columns-scala
[[sql-jpa-custom-column-selection-scalar-query-example]]
.Jakarta Persistence native query with a custom column selection
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-custom-column-selection-scalar-query-example]
----
@ -44,7 +44,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-custom-column-sel
[[sql-hibernate-all-columns-scalar-query-example]]
.Hibernate native query selecting all columns
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-all-columns-scalar-query-example]
----
@ -53,7 +53,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-all-columns
[[sql-hibernate-custom-column-selection-scalar-query-example]]
.Hibernate native query with a custom column selection
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-custom-column-selection-scalar-query-example]
----
@ -67,7 +67,7 @@ To avoid the overhead of using `ResultSetMetadata`, or simply to be more explici
[[sql-hibernate-scalar-query-explicit-result-set-example]]
.Hibernate native query with explicit result set selection
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-scalar-query-explicit-result-set-example]
----
@ -81,7 +81,7 @@ It is possible to leave out the type information for all or some of the scalars.
[[sql-hibernate-scalar-query-partial-explicit-result-set-example]]
.Hibernate native query with result set selection that's a partially explicit
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-scalar-query-partial-explicit-result-set-example]
----
@ -100,7 +100,7 @@ The above queries were all about returning scalar values, basically returning th
[[sql-jpa-entity-query-example]]
.Jakarta Persistence native query selecting entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-query-example]
----
@ -109,7 +109,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-query-exam
[[sql-hibernate-entity-query-example]]
.Hibernate native query selecting entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-query-example]
----
@ -121,7 +121,7 @@ the following query will also return a `List` where each element is a `Person` e
[[sql-jpa-entity-query-explicit-result-set-example]]
.Jakarta Persistence native query selecting entities with explicit result set
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-query-explicit-result-set-example]
----
@ -130,7 +130,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-query-expl
[[sql-hibernate-entity-query-explicit-result-set-example]]
.Hibernate native query selecting entities with explicit result set
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-query-explicit-result-set-example]
----
@ -146,7 +146,7 @@ otherwise, a database-specific _column not found_ error will occur.
[[sql-jpa-entity-associations-query-many-to-one-example]]
.Jakarta Persistence native query selecting entities with many-to-one association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-associations-query-many-to-one-example]
----
@ -155,7 +155,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-associatio
[[sql-hibernate-entity-associations-query-many-to-one-example]]
.Hibernate native query selecting entities with many-to-one association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-associations-query-many-to-one-example]
----
@ -169,7 +169,7 @@ It is possible to eagerly join the `Phone` and the `Person` entities to avoid th
[[sql-hibernate-entity-associations-query-many-to-one-join-example]]
.Hibernate native query selecting entities with joined many-to-one association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-associations-query-many-to-one-join-example]
----
@ -191,7 +191,7 @@ Joined entities will only be present for their respective association.
[[sql-hibernate-entity-associations-query-many-to-one-join-tuple-transformer-example]]
.Hibernate native query selecting entities with joined many-to-one association and `TupleTransformer`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-associations-query-many-to-one-join-tuple-transformer-example]
----
@ -203,7 +203,7 @@ It is possible to do the same eager joining for collections (e.g. the `Phone#cal
[[sql-jpa-entity-associations-query-one-to-many-join-example]]
.Jakarta Persistence native query selecting entities with joined one-to-many association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-associations-query-one-to-many-join-example]
----
@ -217,7 +217,7 @@ include::{extrasdir}/sql-jpa-entity-associations-query-one-to-many-join-example.
[[sql-hibernate-entity-associations-query-one-to-many-join-example]]
.Hibernate native query selecting entities with joined one-to-many association
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-associations-query-one-to-many-join-example]
----
@ -242,7 +242,7 @@ Column alias injection is needed in the following query which otherwise throws `
[[sql-jpa-multi-entity-query-example]]
.Jakarta Persistence native query selecting entities with the same column names
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multi-entity-query-example]
----
@ -251,7 +251,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multi-entity-quer
[[sql-hibernate-multi-entity-query-example]]
.Hibernate native query selecting entities with the same column names
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-multi-entity-query-example]
----
@ -267,7 +267,7 @@ The following form is not vulnerable to column name duplication:
[[sql-hibernate-multi-entity-query-alias-example]]
.Hibernate native query selecting entities with the same column names and aliases
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-multi-entity-query-alias-example]
----
@ -330,7 +330,7 @@ It is possible to apply a `ResultTransformer` to native SQL queries, allowing it
[[sql-hibernate-dto-query-example]]
.Hibernate native query selecting DTOs
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/PersonSummaryDTO.java[tags=sql-hibernate-dto-query-example, indent=0]
@ -362,7 +362,7 @@ Native SQL queries which query for entities that are mapped as part of an inheri
[[sql-hibernate-inheritance-query-example]]
.Hibernate native query selecting subclasses
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-inheritance-query-example]
----
@ -381,7 +381,7 @@ Native SQL queries support ordinal as well as named parameters:
[[sql-jpa-query-parameters-example]]
.Jakarta Persistence native query with parameters
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-query-parameters-example]
----
@ -390,7 +390,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-query-parameters-
[[sql-hibernate-query-parameters-example]]
.Hibernate native query with parameters
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-query-parameters-example]
----
@ -433,7 +433,7 @@ To fetch a single column of given table, the named query looks as follows:
[[sql-scalar-NamedNativeQuery-example]]
.Single scalar value `NamedNativeQuery`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-scalar-NamedNativeQuery-example]
----
@ -442,7 +442,7 @@ include::{example-dir-model}/Person.java[tags=sql-scalar-NamedNativeQuery-exampl
[[sql-jpa-scalar-named-query-example]]
.Jakarta Persistence named native query selecting a scalar value
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-scalar-named-query-example]
----
@ -451,7 +451,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-scalar-named-quer
[[sql-hibernate-scalar-named-query-example]]
.Hibernate named native query selecting a scalar value
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-scalar-named-query-example]
----
@ -462,7 +462,7 @@ Selecting multiple scalar values is done like this:
[[sql-multiple-scalar-values-NamedNativeQuery-example]]
.Multiple scalar values `NamedNativeQuery`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-multiple-scalar-values-NamedNativeQuery-example]
----
@ -473,7 +473,7 @@ Without specifying an explicit result type, Hibernate will assume an `Object` ar
[[sql-jpa-multiple-scalar-values-named-query-example]]
.Jakarta Persistence named native query selecting multiple scalar values
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multiple-scalar-values-named-query-example]
----
@ -482,7 +482,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multiple-scalar-v
[[sql-hibernate-multiple-scalar-values-named-query-example]]
.Hibernate named native query selecting multiple scalar values
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-multiple-scalar-values-named-query-example]
----
@ -493,7 +493,7 @@ It's possible to use a DTO to store the resulting scalar values:
[[sql-ConstructorResult-dto-example]]
.DTO to store multiple scalar values
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/PersonNames.java[tags=sql-ConstructorResult-dto-example]
----
@ -502,7 +502,7 @@ include::{example-dir-model}/PersonNames.java[tags=sql-ConstructorResult-dto-exa
[[sql-multiple-scalar-values-dto-NamedNativeQuery-example]]
.Multiple scalar values `NamedNativeQuery` with `ConstructorResult`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-multiple-scalar-values-dto-NamedNativeQuery-example]
----
@ -511,7 +511,7 @@ include::{example-dir-model}/Person.java[tags=sql-multiple-scalar-values-dto-Nam
[[sql-jpa-multiple-scalar-values-dto-named-query-example]]
.Jakarta Persistence named native query selecting multiple scalar values into a DTO
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multiple-scalar-values-dto-named-query-example]
----
@ -520,7 +520,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-multiple-scalar-v
[[sql-hibernate-multiple-scalar-values-dto-named-query-example]]
.Hibernate named native query selecting multiple scalar values into a DTO
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-multiple-scalar-values-dto-named-query-example]
----
@ -532,7 +532,7 @@ to customize the named query using various configurations such as fetch mode, ca
[[sql-multiple-scalar-values-dto-NamedNativeQuery-hibernate-example]]
.Multiple scalar values using `ConstructorResult` and Hibernate `NamedNativeQuery`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Phone.java[tags=sql-multiple-scalar-values-dto-NamedNativeQuery-hibernate-example]
----
@ -541,7 +541,7 @@ include::{example-dir-model}/Phone.java[tags=sql-multiple-scalar-values-dto-Name
[[sql-hibernate-multiple-scalar-values-dto-hibernate-named-query-example]]
.Hibernate `NamedNativeQuery` named native query selecting multiple scalar values into a DTO
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-multiple-scalar-values-dto-hibernate-named-query-example]
----
@ -555,7 +555,7 @@ Considering the following named query:
[[sql-entity-NamedNativeQuery-example]]
.Single-entity `NamedNativeQuery`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-entity-NamedNativeQuery-example]
----
@ -571,7 +571,7 @@ Executing this named native query can be done as follows:
[[sql-jpa-entity-named-query-example]]
.Jakarta Persistence named native entity query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-named-query-example]
----
@ -580,7 +580,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-named-quer
[[sql-hibernate-entity-named-query-example]]
.Hibernate named native entity query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-named-query-example]
----
@ -591,7 +591,7 @@ To join multiple entities, you need to use a `SqlResultSetMapping` for each enti
[[sql-entity-associations-NamedNativeQuery-example]]
.Joined-entities `NamedNativeQuery`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-entity-associations-NamedNativeQuery-example]
----
@ -600,7 +600,7 @@ include::{example-dir-model}/Person.java[tags=sql-entity-associations-NamedNativ
[[sql-jpa-entity-associations_named-query-example]]
.Jakarta Persistence named native entity query with joined associations
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-associations_named-query-example]
----
@ -609,7 +609,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-entity-associatio
[[sql-hibernate-entity-associations_named-query-example]]
.Hibernate named native entity query with joined associations
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-entity-associations_named-query-example]
----
@ -622,7 +622,7 @@ For this example, the following entities are going to be used:
[[sql-composite-key-entity-associations_named-query-example]]
.Entity associations with composite keys and named native queries
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/Dimensions.java[tags=sql-composite-key-entity-associations_named-query-example, indent=0]
@ -637,7 +637,7 @@ include::{doc-emeddable-example-dir}/SpaceShip.java[tags=sql-composite-key-entit
[[sql-jpa-composite-key-entity-associations_named-query-example]]
.Jakarta Persistence named native entity query with joined associations and composite keys
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-composite-key-entity-associations_named-query-example]
----
@ -646,7 +646,7 @@ include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-jpa-composite-key-ent
[[sql-hibernate-composite-key-entity-associations_named-query-example]]
.Hibernate named native entity query with joined associations and composite keys
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/SQLTest.java[tags=sql-hibernate-composite-key-entity-associations_named-query-example]
----
@ -681,7 +681,7 @@ With these placeholders, you can imply the catalog, schema, or both catalog and
So, when running the following native query:
[source, JAVA, indent=0]
[source, java, indent=0]
----
@NamedNativeQuery(
name = "last_30_days_hires",
@ -712,7 +712,7 @@ parameter type, a `REF_CURSOR` or it could just return the result like a functio
[[sql-sp-out-mysql-example]]
.MySQL stored procedure with `OUT` parameter type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-sp-out-mysql-example]
----
@ -723,7 +723,7 @@ To use this stored procedure, you can execute the following Jakarta Persistence
[[sql-jpa-call-sp-out-mysql-example]]
.Calling a MySQL stored procedure with `OUT` parameter type using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-jpa-call-sp-out-mysql-example]
----
@ -732,7 +732,7 @@ include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-jpa-
[[sql-hibernate-call-sp-out-mysql-example]]
.Calling a MySQL stored procedure with `OUT` parameter type using Hibernate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-hibernate-call-sp-out-mysql-example]
----
@ -743,7 +743,7 @@ If the stored procedure outputs the result directly without an `OUT` parameter t
[[sql-sp-mysql-return-no-out-example]]
.MySQL stored procedure without an `OUT` parameter type
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-sp-no-out-mysql-example]
----
@ -754,7 +754,7 @@ You can retrieve the results of the aforementioned MySQL stored procedure as fol
[[sql-jpa-call-sp-no-out-mysql-example]]
.Calling a MySQL stored procedure and fetching the result set without an `OUT` parameter type using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-jpa-call-sp-no-out-mysql-example]
----
@ -763,7 +763,7 @@ include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-jpa-
[[sql-hibernate-call-sp-no-out-mysql-example]]
.Calling a MySQL stored procedure and fetching the result set without an `OUT` parameter type using Hibernate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-hibernate-call-sp-no-out-mysql-example]
----
@ -774,7 +774,7 @@ For a `REF_CURSOR` result sets, we'll consider the following Oracle stored proce
[[sql-sp-ref-cursor-oracle-example]]
.Oracle `REF_CURSOR` stored procedure
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleStoredProcedureTest.java[tags=sql-sp-ref-cursor-oracle-example]
----
@ -790,7 +790,7 @@ This function can be called using the standard Java Persistence API:
[[sql-jpa-call-sp-ref-cursor-oracle-example]]
.Calling an Oracle `REF_CURSOR` stored procedure using Jakarta Persistence
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleStoredProcedureTest.java[tags=sql-jpa-call-sp-ref-cursor-oracle-example]
----
@ -799,7 +799,7 @@ include::{doc-emeddable-example-dir}/OracleStoredProcedureTest.java[tags=sql-jpa
[[sql-hibernate-call-sp-ref-cursor-oracle-example]]
.Calling an Oracle `REF_CURSOR` stored procedure using Hibernate
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleStoredProcedureTest.java[tags=sql-hibernate-call-sp-ref-cursor-oracle-example]
----
@ -810,7 +810,7 @@ If the database defines an SQL function:
[[sql-function-mysql-example]]
.MySQL function
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-function-mysql-example]
----
@ -827,7 +827,7 @@ This limitation is acknowledged and will be addressed by the https://hibernate.a
[[sql-call-function-mysql-example]]
.Calling a MySQL function
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/MySQLStoredProcedureTest.java[tags=sql-call-function-mysql-example]
----
@ -852,7 +852,7 @@ For this purpose, Jakarta Persistence defines the {jpaJavadocUrlPrefix}NamedStor
[[sql-sp-ref-cursor-oracle-named-query-example]]
.Oracle `REF_CURSOR` named query stored procedure
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/Person.java[tags=sql-sp-ref-cursor-oracle-named-query-example]
----
@ -863,7 +863,7 @@ Calling this stored procedure is straightforward, as illustrated by the followin
[[sql-jpa-call-sp-ref-cursor-oracle-named-query-example]]
.Calling an Oracle `REF_CURSOR` stored procedure using a Jakarta Persistence named query
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleStoredProcedureTest.java[tags=sql-jpa-call-sp-ref-cursor-oracle-named-query-example]
----
@ -887,7 +887,7 @@ To filter collections, the `@SQLRestriction` annotation allows customizing the u
[[sql-custom-crud-example]]
.Custom CRUD
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/CustomSQLTest.java[tags=sql-custom-crud-example]
----
@ -926,7 +926,7 @@ Overriding SQL statements for secondary tables is also possible.
[[sql-custom-crud-secondary-table-example]]
.Overriding SQL statements for secondary tables
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/CustomSQLSecondaryTableTest.java[tags=sql-custom-crud-secondary-table-example]
----
@ -945,7 +945,7 @@ Assuming the following stored procedure:
[[sql-sp-soft-delete-example]]
.Oracle stored procedure to soft-delete a given entity
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleCustomSQLWithStoredProcedureTest.java[tags=sql-sp-soft-delete-example]
----
@ -956,7 +956,7 @@ The entity can use this stored procedure to soft-delete the entity in question:
[[sql-sp-custom-crud-example]]
.Customizing the entity delete statement to use the Oracle stored procedure= instead
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{doc-emeddable-example-dir}/OracleCustomSQLWithStoredProcedureTest.java[tags=sql-sp-custom-crud-example]
----

View File

@ -226,7 +226,7 @@ Here is an example using JTS:
[[spatial-types-mapping-example]]
.Type mapping
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-spatial}/SpatialTest.java[tags=spatial-types-mapping-example, indent=0]
----
@ -237,7 +237,7 @@ We can now treat spatial geometries like any other type.
[[spatial-types-point-creation-example]]
.Creating a Point
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-spatial}/SpatialTest.java[tags=spatial-types-point-creation-example]
----

View File

@ -22,7 +22,7 @@ Considering the following Domain Model:
[[schema-generation-domain-model-example]]
.Schema generation Domain Model
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/BaseSchemaGeneratorTest.java[tags=schema-generation-domain-model-example]
----
@ -49,7 +49,7 @@ For instance, considering the following `schema-generation.sql` import file:
[[schema-generation-import-file-example]]
.Schema generation import file
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen-resources}/schema-generation.sql[]
----
@ -80,7 +80,7 @@ Considering the following HBM mapping:
[[schema-generation-database-object-example]]
.Schema generation HBM database-object
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen-resources}/org/hibernate/orm/test/schema/SchemaGenerationTest.hbm.xml[]
----
@ -96,7 +96,7 @@ Hibernate offers the `@Check` annotation so that you can specify an arbitrary SQ
[[schema-generation-database-checks-example]]
.Database check entity mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/CheckTest.java[tag=schema-generation-database-checks-example]
----
@ -108,7 +108,7 @@ a `ConstraintViolationException` is going to be thrown.
[[stag::schema-generation-database-checks-persist-example]]
.Database check failure example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/CheckTest.java[tag=schema-generation-database-checks-persist-example]
----
@ -127,7 +127,7 @@ With Hibernate, you can specify a default value for a given database column usin
[[schema-generation-column-default-value-mapping-example]]
.`@ColumnDefault` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/ColumnDefaultTest.java[tag=schema-generation-column-default-value-mapping-example]
----
@ -150,7 +150,7 @@ This way, when the `name` and or `clientId` attribute is null, the database will
[[schema-generation-column-default-value-persist-example]]
.`@ColumnDefault` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/ColumnDefaultTest.java[tag=schema-generation-column-default-value-persist-example]
----
@ -176,7 +176,7 @@ Considering the following entity mapping, Hibernate generates the unique constra
[[schema-generation-columns-unique-constraint-mapping-example]]
.`@UniqueConstraint` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/UniqueConstraintTest.java[tag=schema-generation-columns-unique-constraint-mapping-example]
----
@ -193,7 +193,7 @@ it's no longer possible to add two books with the same title and for the same au
[[schema-generation-columns-unique-constraint-persist-example]]
.`@UniqueConstraintTest` persist example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/UniqueConstraintTest.java[tag=schema-generation-columns-unique-constraint-persist-example]
----
@ -218,7 +218,7 @@ Considering the following entity mapping. Hibernate generates the index when cre
[[schema-generation-columns-index-mapping-example]]
.`@Index` mapping example
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-schemagen}/IndexTest.java[tag=schema-generation-columns-index-mapping-example]
----

View File

@ -76,7 +76,7 @@ As an example, consider the following domain model -
[[ex-tooling-modelgen-model]]
.`Order` and `Item` entities
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-model}/tooling/Customer.java[tags=tooling-modelgen-model]
include::{example-dir-model}/tooling/Order.java[tags=tooling-modelgen-model]
@ -89,7 +89,7 @@ Given this model, the generator will produce classes named `Customer_`, `Order_`
[[tooling-modelgen-metamodel]]
.`Order_`
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-metamodelgen-generated}/tooling/Order_.java[]
----
@ -101,7 +101,7 @@ Criteria queries for type-safe path references. For example:
[[tooling-modelgen-usage]]
.Static Metamodel usage
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{toolingTestsDir}/modelgen/ModelGenTests.java[tags=tooling-modelgen-usage]
----

View File

@ -116,7 +116,7 @@ Let's take a look at using the Transaction API in the various environments.
[[transactions-api-jdbc-example]]
.Using Transaction API in JDBC
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-transaction}/TransactionsTest.java[tags=transactions-api-jdbc-example]
----
@ -125,7 +125,7 @@ include::{example-dir-transaction}/TransactionsTest.java[tags=transactions-api-j
[[transactions-api-cmt-example]]
.Using Transaction API in JTA (CMT)
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-transaction}/TransactionsTest.java[tags=transactions-api-cmt-example]
----
@ -134,7 +134,7 @@ include::{example-dir-transaction}/TransactionsTest.java[tags=transactions-api-c
[[transactions-api-bmt-example]]
.Using Transaction API in JTA (BMT)
====
[source, JAVA, indent=0]
[source, java, indent=0]
----
include::{example-dir-transaction}/TransactionsTest.java[tags=transactions-api-bmt-example]
----