mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-16097 Move all tests from documentation into hibernate-core
This commit is contained in:
parent
5b2b7b4ab9
commit
5491bcd5d4
@ -12,10 +12,9 @@ plugins {
|
||||
*/
|
||||
|
||||
|
||||
apply from: rootProject.file( 'gradle/java-module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/module.gradle' )
|
||||
apply from: rootProject.file( 'gradle/releasable.gradle' )
|
||||
|
||||
apply plugin: 'org.hibernate.matrix-test'
|
||||
apply plugin: 'org.hibernate.orm.build.reports'
|
||||
|
||||
tasks.build.dependsOn 'buildDocs'
|
||||
@ -38,46 +37,16 @@ dependencies {
|
||||
reportAggregation project(':hibernate-ant')
|
||||
reportAggregation project(':hibernate-enhance-maven-plugin')
|
||||
reportAggregation project(':hibernate-jpamodelgen')
|
||||
|
||||
implementation project( ':hibernate-core' )
|
||||
|
||||
annotationProcessor project( ':hibernate-jpamodelgen' )
|
||||
|
||||
testImplementation project(':hibernate-testing')
|
||||
testImplementation project(':hibernate-envers')
|
||||
testImplementation project(':hibernate-spatial')
|
||||
testImplementation project(':hibernate-jcache')
|
||||
testImplementation project( path: ':hibernate-core', configuration: 'tests' )
|
||||
|
||||
testImplementation 'org.apache.commons:commons-lang3:3.4'
|
||||
testImplementation 'org.osgi:org.osgi.core:4.3.1'
|
||||
|
||||
testImplementation testLibs.mockito
|
||||
testImplementation testLibs.mockitoInline
|
||||
|
||||
testImplementation jakartaLibs.jaxbApi
|
||||
testImplementation jakartaLibs.jaxb
|
||||
testImplementation jakartaLibs.jsonb
|
||||
testImplementation libs.jacksonXml
|
||||
|
||||
testRuntimeOnly testLibs.wildFlyTxnClient
|
||||
testRuntimeOnly(libs.ehcache3) {
|
||||
capabilities {
|
||||
requireCapability 'org.ehcache.modules:ehcache-xml-jakarta'
|
||||
}
|
||||
}
|
||||
// Needed for JSON tests
|
||||
testRuntimeOnly libs.jackson
|
||||
}
|
||||
|
||||
|
||||
if ( project.ormVersion.isSnapshot ) {
|
||||
// only run the ci build tasks for SNAPSHOT versions
|
||||
task ciBuild( dependsOn: [clean, test] )
|
||||
task ciBuild( dependsOn: [clean] )
|
||||
tasks.release.enabled false
|
||||
}
|
||||
else {
|
||||
tasks.release.dependsOn clean, test
|
||||
tasks.release.dependsOn clean
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -303,12 +272,3 @@ tasks.withType(AsciidoctorTask).all {
|
||||
backends 'html5'
|
||||
}
|
||||
}
|
||||
|
||||
// resources inherently exclude sources
|
||||
sourceSets.test.resources {
|
||||
setSrcDirs( ['src/test/java','src/test/resources'] )
|
||||
}
|
||||
|
||||
|
||||
checkstyleMain.exclude '**/org/hibernate/userguide/model/*'
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
:sourcedir: ../../../../test/java/org/hibernate/userguide/mapping
|
||||
:root-project-dir: ../../../../../..
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:sourcedir: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping
|
||||
:extrasdir: extras
|
||||
:originalextrasdir: ../chapters/domain/extras
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
[[batch]]
|
||||
== Batching
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-doc-batch: {documentation-project-dir}/src/test/java/org/hibernate/userguide/batch
|
||||
:example-dir-doc-batch: {core-project-dir}/src/test/java/org/hibernate/orm/test/batch
|
||||
:example-dir-bulkid: {core-project-dir}/src/test/java/org/hibernate/orm/test/bulkid
|
||||
:extrasdir: extras
|
||||
|
||||
@ -49,7 +48,7 @@ Since version 5.2, Hibernate allows overriding the global JDBC batch size given
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-session-jdbc-batch-size-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-jdbc-batch-size-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -63,7 +62,7 @@ The following example shows an anti-pattern for batch inserts.
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-session-batch-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-batch-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -91,7 +90,7 @@ When you make new objects persistent, employ methods `flush()` and `clear()` to
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-session-batch-insert-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-batch-insert-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -106,7 +105,7 @@ In addition, use method `scroll()` to take advantage of server-side cursors for
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-session-scroll-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-session-scroll-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -152,7 +151,7 @@ IMPORTANT: Due to the lack of a first-level cache, stateless sessions are vulner
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-stateless-session-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-stateless-session-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -208,7 +207,7 @@ You can use sub-queries in the `WHERE` clause, and the sub-queries themselves ca
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-jpql-update-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-update-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -217,7 +216,7 @@ include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-jpql-update-exam
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-hql-update-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-update-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -229,7 +228,7 @@ You can use a versioned update to force Hibernate to reset the version or timest
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-hql-update-version-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-update-version-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -245,7 +244,7 @@ This feature is only available in HQL since it's not standardized by Jakarta Per
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-jpql-delete-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-jpql-delete-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -254,7 +253,7 @@ include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-jpql-delete-exam
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-hql-delete-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-delete-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -312,7 +311,7 @@ in which case the seed value defined by the `org.hibernate.type.descriptor.java.
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-doc-batch}/BatchTest.java[tags=batch-bulk-hql-insert-example]
|
||||
include::{example-dir-doc-batch}/BatchTests.java[tags=batch-bulk-hql-insert-example]
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
[[bootstrap]]
|
||||
== Bootstrap
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-boot: {documentation-project-dir}/src/test/java/org/hibernate/userguide/bootstrap
|
||||
:example-dir-boot-spi: {core-project-dir}/src/test/java/org/hibernate/orm/test/bootstrap/spi
|
||||
:core-test-base: {core-project-dir}/src/test/java/org/hibernate/orm/test
|
||||
:example-dir-boot: {core-test-base}/bootstrap
|
||||
:example-dir-boot-spi: {core-test-base}/bootstrap/spi
|
||||
:extrasdir: extras
|
||||
|
||||
The term bootstrapping refers to initializing and starting a software component.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[caching]]
|
||||
== Caching
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-caching: {documentation-project-dir}/src/test/java/org/hibernate/userguide/caching
|
||||
:jcache-project-dir: {root-project-dir}/hibernate-jcache
|
||||
:example-dir-caching: {jcache-project-dir}/src/test/java/org/hibernate/orm/test/caching
|
||||
|
||||
At runtime, Hibernate handles moving data into and out of the second-level cache in response to the operations performed by the `Session`, which acts as a transaction-level cache of persistent data.
|
||||
Once an entity becomes managed, that object is added to the internal cache of the current persistence context (`EntityManager` or `Session`).
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[access]]
|
||||
=== Access strategies
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-access: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping/access
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-access: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping/access
|
||||
:extrasdir: extras
|
||||
|
||||
As a Jakarta Persistence provider, Hibernate can introspect both the entity attributes (instance fields) or the accessors (instance properties).
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[associations]]
|
||||
=== Associations
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-association: {documentation-project-dir}/src/test/java/org/hibernate/userguide/associations
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-association: {core-project-dir}/src/test/java/org/hibernate/orm/test/associations
|
||||
:extrasdir: extras/associations
|
||||
|
||||
Associations describe how two or more entities form a relationship based on a database joining semantics.
|
||||
|
@ -1,13 +1,12 @@
|
||||
[[basic]]
|
||||
=== Basic values
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:documentation-example-base: {documentation-project-dir}/src/test/
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:example-dir-basic-mapping: {documentation-example-base}/java/org/hibernate/userguide/mapping
|
||||
:example-dir-resources: {documentation-example-base}/resources/org/hibernate/userguide/
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:core-test-base: {core-project-dir}/src/test
|
||||
:example-dir-basic-mapping: {core-test-base}/java/org/hibernate/orm/test/mapping
|
||||
:example-dir-resources: {core-test-base}/resources/org/hibernate/orm/test/
|
||||
:example-dir-generated: {core-test-base}/java/org/hibernate/orm/test/mapping/generated
|
||||
:example-dir-converter: {core-test-base}/java/org/hibernate/orm/test/mapping/converted/converter
|
||||
:extrasdir: extras
|
||||
|
@ -2,8 +2,6 @@
|
||||
=== Collections
|
||||
:majorMinorVersion: 6.2
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-collection-doc: {documentation-project-dir}/src/test/java/org/hibernate/userguide/collections
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:core-test-base: {core-project-dir}/src/test/java
|
||||
:example-dir-collection: {core-test-base}/org/hibernate/orm/test/mapping/collections
|
||||
@ -484,7 +482,7 @@ Behind the scenes, Hibernate requires an association table to manage the parent-
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalBagTest.java[tags=collections-unidirectional-bag-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalBagTest.java[tags=collections-unidirectional-bag-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -507,7 +505,7 @@ By marking the parent side with the `CascadeType.ALL` attribute, the unidirectio
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalBagTest.java[tags=collections-unidirectional-bag-lifecycle-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalBagTest.java[tags=collections-unidirectional-bag-lifecycle-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -536,7 +534,7 @@ The `@ManyToOne` side is the owning side of the bidirectional bag association, w
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalBagTest.java[tags=collections-bidirectional-bag-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalBagTest.java[tags=collections-bidirectional-bag-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -550,7 +548,7 @@ include::{extrasdir}/collections-bidirectional-bag-example.sql[]
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalBagTest.java[tags=collections-bidirectional-bag-lifecycle-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalBagTest.java[tags=collections-bidirectional-bag-lifecycle-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -564,7 +562,7 @@ include::{extrasdir}/collections-bidirectional-bag-lifecycle-example.sql[]
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalBagOrphanRemovalTest.java[tags=collections-bidirectional-bag-orphan-removal-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalBagOrphanRemovalTest.java[tags=collections-bidirectional-bag-orphan-removal-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -594,7 +592,7 @@ When using the `@OrderBy` annotation, the mapping looks as follows:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalOrderedByListTest.java[tags=collections-unidirectional-ordered-list-order-by-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalOrderedByListTest.java[tags=collections-unidirectional-ordered-list-order-by-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -626,7 +624,7 @@ Another ordering option is to use the `@OrderColumn` annotation:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalOrderColumnListTest.java[tags=collections-unidirectional-ordered-list-order-column-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalOrderColumnListTest.java[tags=collections-unidirectional-ordered-list-order-column-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -659,7 +657,7 @@ The mapping is similar with the <<collections-bidirectional-bag>> example, just
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalOrderByListTest.java[tags=collections-bidirectional-ordered-list-order-by-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalOrderByListTest.java[tags=collections-bidirectional-ordered-list-order-by-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -672,7 +670,7 @@ When using the `@OrderColumn` annotation, the `order_id` column is going to be e
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalOrderColumnListTest.java[tags=collections-bidirectional-ordered-list-order-column-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalOrderColumnListTest.java[tags=collections-bidirectional-ordered-list-order-column-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -693,7 +691,7 @@ You can customize the ordinal of the underlying ordered list by using the https:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/OrderColumnListIndexBaseTest.java[tags=collections-customizing-ordered-list-ordinal-mapping-example,indent=0]
|
||||
include::{example-dir-collection}/OrderColumnListIndexBaseTest.java[tags=collections-customizing-ordered-list-ordinal-mapping-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -704,7 +702,7 @@ When inserting two `Phone` records, Hibernate is going to start the List index f
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/OrderColumnListIndexBaseTest.java[tags=collections-customizing-ordered-list-ordinal-persist-example,indent=0]
|
||||
include::{example-dir-collection}/OrderColumnListIndexBaseTest.java[tags=collections-customizing-ordered-list-ordinal-persist-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -729,7 +727,7 @@ by the number of characters of the `name` attribute.
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/OrderedBySQLTest.java[tags=collections-customizing-ordered-by-sql-clause-mapping-example,indent=0]
|
||||
include::{example-dir-collection}/OrderedBySQLTest.java[tags=collections-customizing-ordered-by-sql-clause-mapping-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -740,7 +738,7 @@ When fetching the `articles` collection, Hibernate uses the ORDER BY SQL clause
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/OrderedBySQLTest.java[tags=collections-customizing-ordered-by-sql-clause-fetching-example,indent=0]
|
||||
include::{example-dir-collection}/OrderedBySQLTest.java[tags=collections-customizing-ordered-by-sql-clause-fetching-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -764,7 +762,7 @@ The unidirectional set uses a link table to hold the parent-child associations a
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalSetTest.java[tags=collections-unidirectional-set-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalSetTest.java[tags=collections-unidirectional-set-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -789,7 +787,7 @@ The lifecycle is just like with bidirectional bags except for the duplicates whi
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalSetTest.java[tags=collections-bidirectional-set-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalSetTest.java[tags=collections-bidirectional-set-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -809,7 +807,7 @@ A `SortedSet` that relies on the natural sorting order given by the child elemen
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalSortedSetTest.java[tags=collections-unidirectional-sorted-set-natural-comparator-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalSortedSetTest.java[tags=collections-unidirectional-sorted-set-natural-comparator-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -822,7 +820,7 @@ To provide a custom sorting logic, Hibernate also provides a `@SortComparator` a
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalComparatorSortedSetTest.java[tags=collections-unidirectional-sorted-set-custom-comparator-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalComparatorSortedSetTest.java[tags=collections-unidirectional-sorted-set-custom-comparator-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -836,9 +834,9 @@ The `@SortNatural` and `@SortComparator` work the same for bidirectional sorted
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalSortedSetTest.java[tags=collections-bidirectional-sorted-set-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalSortedSetTest.java[tags=collections-bidirectional-sorted-set-example,indent=0]
|
||||
|
||||
include::{example-dir-collection-doc}/UnidirectionalComparatorSortedSetTest.java[lines=75..77,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalComparatorSortedSetTest.java[lines=75..77,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -871,7 +869,7 @@ A map of value type must use the `@ElementCollection` annotation, just like valu
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/ElementCollectionMapTest.java[tags=collections-map-value-type-entity-key-example,indent=0]
|
||||
include::{example-dir-collection}/ElementCollectionMapTest.java[tags=collections-map-value-type-entity-key-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -887,7 +885,7 @@ Adding entries to the map generates the following SQL statements:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/ElementCollectionMapTest.java[tags=collections-map-value-type-entity-key-add-example,indent=0]
|
||||
include::{example-dir-collection}/ElementCollectionMapTest.java[tags=collections-map-value-type-entity-key-add-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -925,7 +923,7 @@ Since we want to map all the calls by their associated `java.util.Date`, not by
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/MapKeyTypeTest.java[tags=collections-map-custom-key-type-mapping-example,indent=0]
|
||||
include::{example-dir-collection}/MapKeyTypeTest.java[tags=collections-map-custom-key-type-mapping-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -940,7 +938,7 @@ Considering you have the following `PhoneNumber` interface with an implementatio
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/MapKeyClassTest.java[tags=collections-map-key-class-type-mapping-example,indent=0]
|
||||
include::{example-dir-collection}/MapKeyClassTest.java[tags=collections-map-key-class-type-mapping-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
@ -952,7 +950,7 @@ If you want to use the `PhoneNumber` interface as a `java.util.Map` key, then yo
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/MapKeyClassTest.java[tags=collections-map-key-class-mapping-example,indent=0]
|
||||
include::{example-dir-collection}/MapKeyClassTest.java[tags=collections-map-key-class-mapping-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -969,7 +967,7 @@ Hibernate generates the following SQL statements:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/MapKeyClassTest.java[tags=collections-map-key-class-persist-example,indent=0]
|
||||
include::{example-dir-collection}/MapKeyClassTest.java[tags=collections-map-key-class-persist-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -986,7 +984,7 @@ Hibernate generates the following SQL statements:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/MapKeyClassTest.java[tags=collections-map-key-class-fetch-example,indent=0]
|
||||
include::{example-dir-collection}/MapKeyClassTest.java[tags=collections-map-key-class-fetch-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -1013,7 +1011,7 @@ The `@MapKey` annotation is used to define the entity attribute used as a key of
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/UnidirectionalMapTest.java[tags=collections-map-unidirectional-example,indent=0]
|
||||
include::{example-dir-collection}/UnidirectionalMapTest.java[tags=collections-map-unidirectional-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -1034,7 +1032,7 @@ In the following example, you can see that `@MapKeyEnumerated` was used so that
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/BidirectionalMapTest.java[tags=collections-map-bidirectional-example,indent=0]
|
||||
include::{example-dir-collection}/BidirectionalMapTest.java[tags=collections-map-bidirectional-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -1068,7 +1066,7 @@ but now, Hibernate will leverage the native array data types if possible.
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/ArrayTest.java[tags=collections-array-as-basic-example,indent=0]
|
||||
include::{example-dir-collection}/ArrayTest.java[tags=collections-array-as-basic-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
@ -1091,7 +1089,7 @@ default mapped like basic arrays as depicted in the <<collections-array-as-basic
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-collection-doc}/CollectionTest.java[tags=collections-as-basic-example,indent=0]
|
||||
include::{example-dir-collection}/CollectionTest.java[tags=collections-as-basic-example,indent=0]
|
||||
----
|
||||
|
||||
[source,sql]
|
||||
|
@ -1,9 +1,9 @@
|
||||
[[dynamic-model]]
|
||||
=== Dynamic Model
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-dynamic: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping/dynamic
|
||||
:example-dir-resources: {documentation-project-dir}/src/test/resources/org/hibernate/userguide/mapping/dynamic
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-dynamic: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping/dynamic
|
||||
:example-dir-resources: {core-project-dir}/src/test/resources/org/hibernate/orm/test/mapping/dynamic
|
||||
:extrasdir: extras
|
||||
|
||||
[IMPORTANT]
|
||||
|
@ -1,11 +1,9 @@
|
||||
[[embeddables]]
|
||||
=== Embeddable values
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:documentation-example-base: {documentation-project-dir}/src/test/java
|
||||
:example-dir-emeddable: {documentation-example-base}/org/hibernate/userguide/mapping/embeddable
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:core-test-base: {root-project-dir}/hibernate-core/src/test/java
|
||||
:example-dir-emeddable: {core-test-base}/org/hibernate/orm/test/mapping/embeddable
|
||||
:example-dir-embeddableinstantiator: {core-test-base}/org/hibernate/orm/test/mapping/embeddable/strategy/instantiator
|
||||
:example-dir-compositeusertype: {core-test-base}/org/hibernate/orm/test/mapping/embeddable/strategy/usertype
|
||||
:extrasdir: extras
|
||||
|
@ -1,11 +1,11 @@
|
||||
[[entity]]
|
||||
=== Entity types
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-locking: {documentation-project-dir}/src/test/java/org/hibernate/userguide/locking
|
||||
:example-dir-mapping: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping
|
||||
:example-dir-proxy: {documentation-project-dir}/src/test/java/org/hibernate/userguide/proxy
|
||||
:example-dir-persister: {documentation-project-dir}/src/test/java/org/hibernate/userguide/persister
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:core-test-base: {core-project-dir}/src/test/java/org/hibernate/orm/test
|
||||
:example-dir-mapping: {core-test-base}/mapping
|
||||
:example-dir-proxy: {core-test-base}/proxy
|
||||
:example-dir-persister: {core-test-base}/persister
|
||||
:extrasdir: extras
|
||||
|
||||
.Usage of the word _entity_
|
||||
|
@ -1,10 +1,10 @@
|
||||
[[identifiers]]
|
||||
=== Identifiers
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-identifier: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping/identifier
|
||||
:example-dir-associations: {documentation-project-dir}/src/test/java/org/hibernate/userguide/associations
|
||||
:core-test-base: {root-project-dir}/hibernate-core/src/test/java
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:core-test-base: {core-project-dir}/src/test/java/org/hibernate/orm/test
|
||||
:example-dir-identifier: {core-test-base}/mapping/identifier
|
||||
:example-dir-associations: {core-test-base}/associations
|
||||
:jpaJavadocUrl: https://javadoc.io/doc/jakarta.persistence/jakarta.persistence-api/latest/jakarta.persistence
|
||||
:extrasdir: extras
|
||||
|
||||
@ -578,9 +578,9 @@ and type-safe definition and configuration of custom `org.hibernate.id.Identifie
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{core-test-base}/org/hibernate/orm/test/id/custom/CustomSequenceGenerator.java[tag=identifiers-IdGeneratorType-example, indent=0]
|
||||
include::{core-test-base}/id/custom/CustomSequenceGenerator.java[tag=identifiers-IdGeneratorType-example, indent=0]
|
||||
|
||||
include::{core-test-base}/org/hibernate/orm/test/id/custom/Sequence.java[tag=identifiers-IdGeneratorType-example, indent=0]
|
||||
include::{core-test-base}/id/custom/Sequence.java[tag=identifiers-IdGeneratorType-example, indent=0]
|
||||
----
|
||||
====
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[entity-inheritance]]
|
||||
=== Inheritance
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-inheritance: {documentation-project-dir}/src/test/java/org/hibernate/userguide/inheritance
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-inheritance: {core-project-dir}/src/test/java/org/hibernate/orm/test/inheritance
|
||||
:extrasdir: extras/inheritance
|
||||
|
||||
Although relational database systems don't provide support for inheritance, Hibernate provides several strategies to leverage this object-oriented trait onto domain model entities:
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[naming]]
|
||||
=== Naming strategies
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-naming: {documentation-project-dir}/src/test/java/org/hibernate/userguide/naming
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-naming: {core-project-dir}/src/test/java/org/hibernate/orm/test/naming
|
||||
|
||||
Part of the mapping of an object model to the relational database is
|
||||
mapping names from the object model to the corresponding database names.
|
||||
|
@ -1,8 +1,10 @@
|
||||
[[naturalid]]
|
||||
=== Natural Ids
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-naturalid: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping/identifier
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-naturalid: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping/identifier
|
||||
:jcache-project-dir: {root-project-dir}/hibernate-jcache
|
||||
:example-dir-caching: {jcache-project-dir}/src/test/java/org/hibernate/orm/test/caching
|
||||
:extrasdir: extras
|
||||
|
||||
Natural ids represent domain model unique identifiers that have a meaning in the real world too.
|
||||
@ -157,6 +159,6 @@ Not only can this NaturalId-to-PK resolution be cached in the Session, but we ca
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
include::{example-dir-naturalid}/CacheableNaturalIdTest.java[tags=naturalid-cacheable-mapping-example,indent=0]
|
||||
include::{example-dir-caching}/CacheableNaturalIdTest.java[tags=naturalid-cacheable-mapping-example,indent=0]
|
||||
----
|
||||
====
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[partitioning]]
|
||||
=== Partitioning
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-partition-key: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping/identifier
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-partition-key: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping/identifier
|
||||
:extrasdir: extras
|
||||
|
||||
In data management, it is sometimes necessary to split data of a table into various (physical) partitions,
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[mapping-types]]
|
||||
=== Mapping types
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-mapping: {documentation-project-dir}/src/test/java/org/hibernate/userguide/mapping
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-mapping: {core-project-dir}/src/test/java/org/hibernate/orm/test/mapping
|
||||
:extrasdir: extras/types
|
||||
|
||||
Hibernate understands both the Java and JDBC representations of application data.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[envers]]
|
||||
== Envers
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-envers: {documentation-project-dir}/src/test/java/org/hibernate/userguide/envers
|
||||
:envers-project-dir: {root-project-dir}/hibernate-envers
|
||||
:example-dir-envers: {envers-project-dir}/src/test/java/org/hibernate/orm/test/envers
|
||||
:extrasdir: extras
|
||||
|
||||
[[envers-basics]]
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[events]]
|
||||
== Interceptors and events
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-event: {documentation-project-dir}/src/test/java/org/hibernate/userguide/events
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-event: {core-project-dir}/src/test/java/org/hibernate/orm/test/events
|
||||
:extrasdir: extras
|
||||
|
||||
It is useful for the application to react to certain events that occur inside Hibernate.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[fetching]]
|
||||
== Fetching
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-fetching: {documentation-project-dir}/src/test/java/org/hibernate/userguide/fetching
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-fetching: {core-project-dir}/src/test/java/org/hibernate/orm/test/fetching
|
||||
:extrasdir: extras
|
||||
|
||||
Fetching, essentially, is the process of grabbing data from the database and making it available to the application.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[flushing]]
|
||||
== Flushing
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-flushing: {documentation-project-dir}/src/test/java/org/hibernate/userguide/flush
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-flushing: {core-project-dir}/src/test/java/org/hibernate/orm/test/flush
|
||||
:extrasdir: extras
|
||||
|
||||
Flushing is the process of synchronizing the state of the persistence context with the underlying database.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[locking]]
|
||||
== Locking
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-locking: {documentation-project-dir}/src/test/java/org/hibernate/userguide/locking
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-locking: {core-project-dir}/src/test/java/org/hibernate/orm/test/locking
|
||||
:extrasdir: extras
|
||||
|
||||
In a relational database, locking refers to actions taken to prevent data from changing between the time it is read and the time is used.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[multitenacy]]
|
||||
== Multitenancy
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-multitenancy: {documentation-project-dir}/src/test/java/org/hibernate/userguide/multitenancy
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-multitenancy: {core-project-dir}/src/test/java/org/hibernate/orm/test/multitenancy
|
||||
:extrasdir: extras
|
||||
|
||||
[[multitenacy-intro]]
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[BytecodeEnhancement]]
|
||||
=== Bytecode Enhancement
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-enhancement: {documentation-project-dir}/src/test/java/org/hibernate/userguide/pc
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-enhancement: {core-project-dir}/src/test/java/org/hibernate/orm/test/pc
|
||||
|
||||
Hibernate "grew up" not supporting bytecode enhancement at all.
|
||||
At that time, Hibernate only supported proxy-based alternative for lazy loading and always used diff-based dirty calculation.
|
||||
|
@ -1,9 +1,10 @@
|
||||
[[pc]]
|
||||
== Persistence Context
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-pc: {documentation-project-dir}/src/test/java/org/hibernate/userguide/pc
|
||||
:example-dir-caching: {documentation-project-dir}/src/test/java/org/hibernate/userguide/caching
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-pc: {core-project-dir}/src/test/java/org/hibernate/orm/test/pc
|
||||
:jcache-project-dir: {root-project-dir}/hibernate-jcache
|
||||
:example-dir-caching: {jcache-project-dir}/src/test/java/org/hibernate/orm/test/caching
|
||||
:extrasdir: extras
|
||||
|
||||
Both the `org.hibernate.Session` API and `jakarta.persistence.EntityManager` API represent a context for dealing with persistent data.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[criteria]]
|
||||
== Criteria
|
||||
:root-project-dir: ../../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-criteria: {documentation-project-dir}/src/test/java/org/hibernate/userguide/criteria
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-criteria: {core-project-dir}/src/test/java/org/hibernate/orm/test/query/criteria
|
||||
|
||||
Criteria queries offer a type-safe alternative to HQL, JPQL and native SQL queries.
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
[[hql]]
|
||||
== Java API for HQL and JPQL
|
||||
:root-project-dir: ../../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:example-dir-query: {documentation-project-dir}/src/test/java/org/hibernate/userguide/hql
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-query: {core-project-dir}/src/test/java/org/hibernate/orm/test/hql
|
||||
:extrasdir: extras
|
||||
|
||||
The Hibernate Query Language (HQL) and the Java Persistence Query Language (JPQL) are object-oriented query languages based on SQL and very similar in flavor to SQL.
|
||||
|
@ -1,9 +1,10 @@
|
||||
[[query-language]]
|
||||
== Hibernate Query Language
|
||||
:root-project-dir: ../../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:example-dir-hql: ../../../../../../test/java/org/hibernate/userguide/hql
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-hql: {core-project-dir}/src/test/java/org/hibernate/orm/test/hql
|
||||
:extrasdir: extras
|
||||
|
||||
This chapter describes Hibernate Query Language (HQL) and Jakarta Persistence Query Language (JPQL).
|
||||
@ -196,9 +197,9 @@ A single HQL `update` statement might result in multiple SQL update statements e
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-hql}/../batch/BatchTest.java[tags=batch-bulk-jpql-update-example]
|
||||
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-jpql-update-example]
|
||||
|
||||
include::{example-dir-hql}/../batch/BatchTest.java[tags=batch-bulk-hql-update-example]
|
||||
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-hql-update-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -224,7 +225,7 @@ Adding the keyword `versioned`—writing `update versioned`—specifies
|
||||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{example-dir-hql}/../batch/BatchTest.java[tags=batch-bulk-hql-update-version-example]
|
||||
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-hql-update-version-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -295,7 +296,7 @@ include::{example-dir-hql}/HQLTest.java[tags=hql-insert-example]
|
||||
|
||||
[source, SQL, indent=0]
|
||||
----
|
||||
include::{example-dir-hql}/../batch/BatchTest.java[tags=batch-bulk-hql-insert-example]
|
||||
include::{example-dir-hql}/../batch/BatchTests.java[tags=batch-bulk-hql-insert-example]
|
||||
----
|
||||
====
|
||||
|
||||
@ -864,7 +865,7 @@ This function truncates a date, time, or datetime to the temporal unit specified
|
||||
The syntax is `truncate(datetime, field)`. Supported temporal units are: `year`, `month`, `day`, `hour`, `minute` or `second`.
|
||||
|
||||
Truncating a date, time or datetime value translates to obtaining a value of the same type in which all temporal units smaller than `field` have been pruned.
|
||||
For hours, minutes and second this means setting them to `00`. For months and days, this means setting them to `01'.
|
||||
For hours, minutes and second this means setting them to `00`. For months and days, this means setting them to `01`.
|
||||
|
||||
[[hql-string-functions]]
|
||||
==== Functions for working with strings
|
||||
|
@ -1,9 +1,10 @@
|
||||
[[sql]]
|
||||
== Native SQL Queries
|
||||
:root-project-dir: ../../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:doc-emeddable-example-dir: ../../../../../../test/java/org/hibernate/userguide/sql
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:doc-emeddable-example-dir: {core-project-dir}/src/test/java/org/hibernate/orm/test/sql
|
||||
:extrasdir: extras
|
||||
|
||||
You may also express queries in the native SQL dialect of your database.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[spatial]]
|
||||
== Spatial
|
||||
:root-project-dir: ../../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-spatial: {documentation-project-dir}/src/test/java/org/hibernate/userguide/spatial
|
||||
:spatial-project-dir: {root-project-dir}/hibernate-spatial
|
||||
:example-dir-spatial: {spatial-project-dir}/src/test/java/org/hibernate/spatial/testing
|
||||
:extrasdir: extras
|
||||
|
||||
[[spatial-overview]]
|
||||
|
@ -1,9 +1,9 @@
|
||||
[[schema-generation]]
|
||||
== Schema generation
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-schemagen: {documentation-project-dir}/src/test/java/org/hibernate/userguide/schema
|
||||
:example-dir-schemagen-resources: {documentation-project-dir}/src/test/resources
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-schemagen: {core-project-dir}/src/test/java/org/hibernate/orm/test/schema
|
||||
:example-dir-schemagen-resources: {core-project-dir}/src/test/resources
|
||||
:extrasdir: extras
|
||||
|
||||
Hibernate allows you to generate the database from the entity mappings.
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[tooling]]
|
||||
== Build Tool Integration
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
|
||||
Hibernate provides build-time services available as plugins for
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
[[tooling-modelgen]]
|
||||
=== Static Metamodel Generator
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-model: {documentation-project-dir}/src/main/java/org/hibernate/userguide/model
|
||||
:example-dir-metamodelgen-generated: {documentation-project-dir}/target/generated/sources/annotationProcessor/java/main/org/hibernate/userguide/model
|
||||
:toolingTestsDir: {documentation-project-dir}/src/test/java/org/hibernate/userguide/tooling
|
||||
:testing-project-dir: {root-project-dir}/hibernate-testing
|
||||
:example-dir-model: {testing-project-dir}/src/main/java/org/hibernate/testing/orm/domain/userguide
|
||||
:example-dir-metamodelgen-generated: {testing-project-dir}/target/generated/sources/annotationProcessor/java/main/org/hibernate/testing/orm/domain/userguide
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:toolingTestsDir: {core-project-dir}/src/test/java/org/hibernate/orm/test/tooling
|
||||
|
||||
Jakarta Persistence defines a typesafe Criteria API which allows `Criteria` queries to be constructed in a
|
||||
strongly-typed manner, utilizing so-called static metamodel classes. For developers, it is important that
|
||||
|
@ -1,8 +1,8 @@
|
||||
[[transactions]]
|
||||
== Transactions and concurrency control
|
||||
:root-project-dir: ../../../../../../..
|
||||
:documentation-project-dir: {root-project-dir}/documentation
|
||||
:example-dir-transaction: {documentation-project-dir}/src/test/java/org/hibernate/userguide/transactions
|
||||
:core-project-dir: {root-project-dir}/hibernate-core
|
||||
:example-dir-transaction: {core-project-dir}/src/test/java/org/hibernate/orm/test/transactions
|
||||
|
||||
It is important to understand that the term transaction has many different yet related meanings in regards to persistence and Object/Relational Mapping.
|
||||
In most use-cases these definitions align, but that is not always the case.
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
@Entity
|
||||
@Table(name = "phone_call")
|
||||
public class Call {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private Phone phone;
|
||||
|
||||
@Column(name = "call_timestamp")
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
private int duration;
|
||||
|
||||
@ManyToOne
|
||||
private Payment payment;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::hql-examples-domain-model-example[]
|
||||
public Call() {}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Phone getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(Phone phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Payment getPayment() {
|
||||
return payment;
|
||||
}
|
||||
|
||||
public void setPayment(Payment payment) {
|
||||
this.payment = payment;
|
||||
}
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
}
|
||||
//end::hql-examples-domain-model-example[]
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public class Payment {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private boolean completed;
|
||||
|
||||
@ManyToOne
|
||||
private Account account;
|
||||
|
||||
@ManyToOne
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::hql-examples-domain-model-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
public void setCompleted(boolean completed) {
|
||||
this.completed = completed;
|
||||
}
|
||||
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
}
|
||||
//end::hql-examples-domain-model-example[]
|
@ -1,269 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.ColumnResult;
|
||||
import jakarta.persistence.ConstructorResult;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityResult;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.FieldResult;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MapKeyEnumerated;
|
||||
import jakarta.persistence.NamedNativeQuery;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
import jakarta.persistence.NamedStoredProcedureQuery;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OrderColumn;
|
||||
import jakarta.persistence.ParameterMode;
|
||||
import jakarta.persistence.QueryHint;
|
||||
import jakarta.persistence.SqlResultSetMapping;
|
||||
import jakarta.persistence.StoredProcedureParameter;
|
||||
import jakarta.persistence.Version;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
//tag::sql-scalar-NamedNativeQuery-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "find_person_name",
|
||||
query =
|
||||
"SELECT name " +
|
||||
"FROM Person ",
|
||||
resultClass = String.class
|
||||
)
|
||||
//end::sql-scalar-NamedNativeQuery-example[]
|
||||
//tag::sql-multiple-scalar-values-NamedNativeQuery-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "find_person_name_and_nickName",
|
||||
query =
|
||||
"SELECT " +
|
||||
" name, " +
|
||||
" nickName " +
|
||||
"FROM Person "
|
||||
)
|
||||
//end::sql-multiple-scalar-values-NamedNativeQuery-example[]
|
||||
// tag::sql-multiple-scalar-values-dto-NamedNativeQuery-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "find_person_name_and_nickName_dto",
|
||||
query =
|
||||
"select " +
|
||||
" name, " +
|
||||
" nickName " +
|
||||
"from Person ",
|
||||
resultSetMapping = "name_and_nickName_dto"
|
||||
)
|
||||
//end::sql-multiple-scalar-values-dto-NamedNativeQuery-example[]
|
||||
//tag::sql-entity-NamedNativeQuery-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "find_person_by_name",
|
||||
query =
|
||||
"select " +
|
||||
" p.id AS \"id\", " +
|
||||
" p.name AS \"name\", " +
|
||||
" p.nickName AS \"nickName\", " +
|
||||
" p.address AS \"address\", " +
|
||||
" p.createdOn AS \"createdOn\", " +
|
||||
" p.version AS \"version\" " +
|
||||
"from Person p " +
|
||||
"where p.name LIKE :name",
|
||||
resultClass = Person.class
|
||||
)
|
||||
//end::sql-entity-NamedNativeQuery-example[]
|
||||
//tag::sql-entity-associations-NamedNativeQuery-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "find_person_with_phones_by_name",
|
||||
query =
|
||||
"select " +
|
||||
" pr.id AS \"pr.id\", " +
|
||||
" pr.name AS \"pr.name\", " +
|
||||
" pr.nickName AS \"pr.nickName\", " +
|
||||
" pr.address AS \"pr.address\", " +
|
||||
" pr.createdOn AS \"pr.createdOn\", " +
|
||||
" pr.version AS \"pr.version\", " +
|
||||
" ph.id AS \"ph.id\", " +
|
||||
" ph.person_id AS \"ph.person_id\", " +
|
||||
" ph.phone_number AS \"ph.number\", " +
|
||||
" ph.phone_type AS \"ph.type\" " +
|
||||
"from Person pr " +
|
||||
"join Phone ph ON pr.id = ph.person_id " +
|
||||
"where pr.name LIKE :name",
|
||||
resultSetMapping = "person_with_phones"
|
||||
)
|
||||
//end::sql-entity-associations-NamedNativeQuery-example[]
|
||||
//tag::sql-entity-associations-NamedNativeQuery-example[]
|
||||
@SqlResultSetMapping(
|
||||
name = "person_with_phones",
|
||||
entities = {
|
||||
@EntityResult(
|
||||
entityClass = Person.class,
|
||||
fields = {
|
||||
@FieldResult( name = "id", column = "pr.id" ),
|
||||
@FieldResult( name = "name", column = "pr.name" ),
|
||||
@FieldResult( name = "nickName", column = "pr.nickName" ),
|
||||
@FieldResult( name = "address", column = "pr.address" ),
|
||||
@FieldResult( name = "createdOn", column = "pr.createdOn" ),
|
||||
@FieldResult( name = "version", column = "pr.version" ),
|
||||
}
|
||||
),
|
||||
@EntityResult(
|
||||
entityClass = Phone.class,
|
||||
fields = {
|
||||
@FieldResult( name = "id", column = "ph.id" ),
|
||||
@FieldResult( name = "person", column = "ph.person_id" ),
|
||||
@FieldResult( name = "number", column = "ph.number" ),
|
||||
@FieldResult( name = "type", column = "ph.type" ),
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
//end::sql-entity-associations-NamedNativeQuery-example[]
|
||||
//tag::sql-multiple-scalar-values-dto-NamedNativeQuery-example[]
|
||||
@SqlResultSetMapping(
|
||||
name = "name_and_nickName_dto",
|
||||
classes = @ConstructorResult(
|
||||
targetClass = PersonNames.class,
|
||||
columns = {
|
||||
@ColumnResult(name = "name"),
|
||||
@ColumnResult(name = "nickName")
|
||||
}
|
||||
)
|
||||
)
|
||||
//end::sql-multiple-scalar-values-dto-NamedNativeQuery-example[]
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
//tag::jpql-api-named-query-example[]
|
||||
@NamedQuery(
|
||||
name = "get_person_by_name",
|
||||
query = "select p from Person p where name = :name"
|
||||
)
|
||||
//end::jpql-api-named-query-example[]
|
||||
// tag::jpa-read-only-entities-native-example[]
|
||||
@NamedQuery(
|
||||
name = "get_read_only_person_by_name",
|
||||
query = "select p from Person p where name = :name",
|
||||
hints = {
|
||||
@QueryHint(
|
||||
name = "org.hibernate.readOnly",
|
||||
value = "true"
|
||||
)
|
||||
}
|
||||
)
|
||||
//end::jpa-read-only-entities-native-example[]
|
||||
@NamedQuery(
|
||||
name = "delete_person",
|
||||
query = "delete Person"
|
||||
)
|
||||
//tag::sql-sp-ref-cursor-oracle-named-query-example[]
|
||||
@NamedStoredProcedureQuery(
|
||||
name = "sp_person_phones",
|
||||
procedureName = "sp_person_phones",
|
||||
parameters = {
|
||||
@StoredProcedureParameter(
|
||||
name = "personId",
|
||||
type = Long.class,
|
||||
mode = ParameterMode.IN
|
||||
),
|
||||
@StoredProcedureParameter(
|
||||
name = "personPhones",
|
||||
type = Class.class,
|
||||
mode = ParameterMode.REF_CURSOR
|
||||
)
|
||||
}
|
||||
)
|
||||
//end::sql-sp-ref-cursor-oracle-named-query-example[]
|
||||
@Entity
|
||||
public class Person {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String address;
|
||||
|
||||
private LocalDateTime createdOn;
|
||||
|
||||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
|
||||
@OrderColumn(name = "order_id")
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
@ElementCollection
|
||||
@MapKeyEnumerated(EnumType.STRING)
|
||||
private Map<AddressType, String> addresses = new HashMap<>();
|
||||
|
||||
@Version
|
||||
private int version;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::hql-examples-domain-model-example[]
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedOn() {
|
||||
return createdOn;
|
||||
}
|
||||
|
||||
public void setCreatedOn(LocalDateTime createdOn) {
|
||||
this.createdOn = createdOn;
|
||||
}
|
||||
|
||||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
|
||||
public Map<AddressType, String> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public void addPhone(Phone phone) {
|
||||
phones.add( phone );
|
||||
phone.setPerson( this );
|
||||
}
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
}
|
||||
//end::hql-examples-domain-model-example[]
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.model;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class PersonPhoneCount {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Number phoneCount;
|
||||
|
||||
public PersonPhoneCount(String name, Number phoneCount) {
|
||||
this.name = name;
|
||||
this.phoneCount = phoneCount;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Number getPhoneCount() {
|
||||
return phoneCount;
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ColumnResult;
|
||||
import jakarta.persistence.ConstructorResult;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapKey;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.SqlResultSetMapping;
|
||||
|
||||
import org.hibernate.annotations.NamedNativeQuery;
|
||||
import org.hibernate.annotations.NamedQuery;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
//tag::jpql-api-hibernate-named-query-example[]
|
||||
@NamedQuery(
|
||||
name = "get_phone_by_number",
|
||||
query = "select p " +
|
||||
"from Phone p " +
|
||||
"where p.number = :number",
|
||||
timeout = 1,
|
||||
readOnly = true
|
||||
)
|
||||
//end::jpql-api-hibernate-named-query-example[]
|
||||
//tag::sql-multiple-scalar-values-dto-NamedNativeQuery-hibernate-example[]
|
||||
@NamedNativeQuery(
|
||||
name = "get_person_phone_count",
|
||||
query = "select pr.name AS name, count(*) AS phoneCount " +
|
||||
"from Phone p " +
|
||||
"join Person pr ON pr.id = p.person_id " +
|
||||
"group BY pr.name",
|
||||
resultSetMapping = "person_phone_count",
|
||||
timeout = 1,
|
||||
readOnly = true
|
||||
)
|
||||
@SqlResultSetMapping(
|
||||
name = "person_phone_count",
|
||||
classes = @ConstructorResult(
|
||||
targetClass = PersonPhoneCount.class,
|
||||
columns = {
|
||||
@ColumnResult(name = "name"),
|
||||
@ColumnResult(name = "phoneCount")
|
||||
}
|
||||
)
|
||||
)
|
||||
//end::sql-multiple-scalar-values-dto-NamedNativeQuery-hibernate-example[]
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
@Entity
|
||||
public class Phone {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Person person;
|
||||
|
||||
@Column(name = "phone_number")
|
||||
private String number;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "phone_type")
|
||||
private PhoneType type;
|
||||
|
||||
@OneToMany(mappedBy = "phone", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Call> calls = new ArrayList<>( );
|
||||
|
||||
//tag::hql-collection-qualification-example[]
|
||||
@OneToMany(mappedBy = "phone")
|
||||
@MapKey(name = "timestamp")
|
||||
private Map<LocalDateTime, Call> callHistory = new HashMap<>();
|
||||
//end::hql-collection-qualification-example[]
|
||||
|
||||
@ElementCollection
|
||||
private List<LocalDateTime> repairTimestamps = new ArrayList<>( );
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::hql-examples-domain-model-example[]
|
||||
public Phone() {}
|
||||
|
||||
public Phone(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
public PhoneType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(PhoneType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<Call> getCalls() {
|
||||
return calls;
|
||||
}
|
||||
|
||||
public Map<LocalDateTime, Call> getCallHistory() {
|
||||
return callHistory;
|
||||
}
|
||||
|
||||
public List<LocalDateTime> getRepairTimestamps() {
|
||||
return repairTimestamps;
|
||||
}
|
||||
|
||||
public void addCall(Call call) {
|
||||
calls.add( call );
|
||||
callHistory.put( call.getTimestamp(), call );
|
||||
call.setPhone( this );
|
||||
}
|
||||
//tag::hql-examples-domain-model-example[]
|
||||
}
|
||||
//end::hql-examples-domain-model-example[]
|
@ -1,35 +0,0 @@
|
||||
package org.hibernate.userguide.osgi._native;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
//tag::osgi-discover-SessionFactory[]
|
||||
public class HibernateUtil {
|
||||
|
||||
private SessionFactory sf;
|
||||
|
||||
public Session getSession() {
|
||||
return getSessionFactory().openSession();
|
||||
}
|
||||
|
||||
private SessionFactory getSessionFactory() {
|
||||
if (sf == null) {
|
||||
Bundle thisBundle = FrameworkUtil.getBundle(
|
||||
HibernateUtil.class
|
||||
);
|
||||
BundleContext context = thisBundle.getBundleContext();
|
||||
|
||||
ServiceReference sr = context.getServiceReference(
|
||||
SessionFactory.class.getName()
|
||||
);
|
||||
sf = (SessionFactory) context.getService(sr);
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
}
|
||||
//end::osgi-discover-SessionFactory[]
|
@ -1,44 +0,0 @@
|
||||
package org.hibernate.userguide.osgi.jpa;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.spi.PersistenceProvider;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
//tag::osgi-discover-EntityManagerFactory[]
|
||||
public class HibernateUtil {
|
||||
|
||||
private EntityManagerFactory emf;
|
||||
|
||||
public EntityManager getEntityManager() {
|
||||
return getEntityManagerFactory().createEntityManager();
|
||||
}
|
||||
|
||||
private EntityManagerFactory getEntityManagerFactory() {
|
||||
if (emf == null) {
|
||||
Bundle thisBundle = FrameworkUtil.getBundle(
|
||||
HibernateUtil.class
|
||||
);
|
||||
BundleContext context = thisBundle.getBundleContext();
|
||||
|
||||
ServiceReference serviceReference = context.getServiceReference(
|
||||
PersistenceProvider.class.getName()
|
||||
);
|
||||
PersistenceProvider persistenceProvider = (PersistenceProvider) context
|
||||
.getService(
|
||||
serviceReference
|
||||
);
|
||||
|
||||
emf = persistenceProvider.createEntityManagerFactory(
|
||||
"YourPersistenceUnitName",
|
||||
null
|
||||
);
|
||||
}
|
||||
return emf;
|
||||
}
|
||||
}
|
||||
//end::osgi-discover-EntityManagerFactory[]
|
@ -1,25 +0,0 @@
|
||||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
#
|
||||
|
||||
hibernate.dialect @db.dialect@
|
||||
hibernate.connection.driver_class @jdbc.driver@
|
||||
hibernate.connection.url @jdbc.url@
|
||||
hibernate.connection.username @jdbc.user@
|
||||
hibernate.connection.password @jdbc.pass@
|
||||
hibernate.connection.init_sql @connection.init_sql@
|
||||
|
||||
hibernate.connection.pool_size 5
|
||||
|
||||
hibernate.format_sql true
|
||||
hibernate.max_fetch_depth 5
|
||||
|
||||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
hibernate.jdbc.batch_size 0
|
||||
|
||||
hibernate.service.allow_crawling=false
|
@ -1,94 +0,0 @@
|
||||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
#
|
||||
appender.stdout.type=Console
|
||||
appender.stdout.name=STDOUT
|
||||
appender.stdout.layout.type=PatternLayout
|
||||
appender.stdout.layout.pattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
|
||||
appender.subsystem.name=subsystem
|
||||
appender.subsystem.type=Console
|
||||
appender.subsystem.layout.type=PatternLayout
|
||||
appender.subsystem.layout.pattern=[subsystem] %5p %15.25c{5} %C{1}:%L - %m%n
|
||||
|
||||
logger.subsystem-root.name=org.hibernate.orm
|
||||
logger.subsystem-root.level=info
|
||||
logger.subsystem-root.additivity=false
|
||||
logger.subsystem-root.appenderRef.subsystem.ref=subsystem
|
||||
|
||||
logger.jdbc-bind.name=org.hibernate.orm.jdbc.bind
|
||||
logger.jdbc-bind.level=trace
|
||||
|
||||
logger.jdbc-extract.name=org.hibernate.orm.jdbc.extract
|
||||
logger.jdbc-extract.level=trace
|
||||
|
||||
|
||||
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=STDOUT
|
||||
|
||||
logger.hibernate.name=org.hibernate
|
||||
logger.hibernate.level=info
|
||||
#logger.hibernate.level=warn
|
||||
|
||||
logger.ejb.name=org.hibernate.ejb
|
||||
logger.ejb.level=info
|
||||
logger.ejb-packaging.name=org.hibernate.ejb.packaging
|
||||
logger.ejb-packaging.level=info
|
||||
logger.reflection.name=org.hibernate.reflection
|
||||
logger.reflection.level=info
|
||||
|
||||
logger.cascades.name=org.hibernate.engine.Cascades
|
||||
#logger.cascades.level=warn
|
||||
|
||||
### log just the SQL
|
||||
logger.sql.name=org.hibernate.SQL
|
||||
logger.sql.level=debug
|
||||
|
||||
### log JDBC bind parameters ###
|
||||
logger.hibernate-type.name=org.hibernate.type
|
||||
logger.hibernate-type.level=trace
|
||||
logger.type-sql.name=org.hibernate.type.descriptor.jdbc
|
||||
logger.type-sql.level=trace
|
||||
logger.table-generator.name=org.hibernate.id.enhanced.TableGenerator
|
||||
logger.table-generator.level=trace
|
||||
logger.identifier-generator-helper.name=org.hibernate.id.IdentifierGeneratorHelper
|
||||
logger.identifier-generator-helper.level=trace
|
||||
logger.abstract-entity-persister.name=org.hibernate.persister.entity.AbstractEntityPersister
|
||||
logger.abstract-entity-persister.level=trace
|
||||
logger.entity-reference-initializer-impl.name=org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl
|
||||
logger.entity-reference-initializer-impl.level=trace
|
||||
|
||||
### log schema export/update ###
|
||||
logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl
|
||||
logger.hbm2ddl.level=info
|
||||
|
||||
### log HQL parse trees
|
||||
logger.hql.name=org.hibernate.hql
|
||||
#logger.hql.level=warn
|
||||
|
||||
### log cache activity ###
|
||||
logger.cache.name=org.hibernate.cache
|
||||
#logger.cache.level=warn
|
||||
|
||||
### log JDBC resource acquisition
|
||||
logger.hibernate-jdbc.name=org.hibernate.jdbc
|
||||
#logger.hibernate-jdbc.level=warn
|
||||
|
||||
### enable the following line if you want to track down connection ###
|
||||
### leakages when using DriverManagerConnectionProvider ###
|
||||
logger.driver-manager-connection-provider.name=org.hibernate.connection.DriverManagerConnectionProvider
|
||||
#logger.driver-manager-connection-provider.level=trace
|
||||
|
||||
### When entity copy merge functionality is enabled using:
|
||||
### hibernate.event.merge.entity_copy_observer=log, the following will
|
||||
### provide information about merged entity copies.
|
||||
logger.entity-copy-allowed-logged-observer.name=org.hibernate.event.internal.EntityCopyAllowedLoggedObserver
|
||||
#logger.entity-copy-allowed-logged-observer.level=warn
|
||||
|
||||
logger.userguide.name=org.hibernate.userguide
|
||||
logger.userguide.level=debug
|
@ -71,6 +71,7 @@ dependencies {
|
||||
testRuntimeOnly libs.byteBuddy
|
||||
testRuntimeOnly testLibs.weld
|
||||
testRuntimeOnly testLibs.wildFlyTxnClient
|
||||
testRuntimeOnly jakartaLibs.jsonb
|
||||
testRuntimeOnly libs.jackson
|
||||
testRuntimeOnly libs.jacksonXml
|
||||
testRuntimeOnly libs.jacksonJsr310
|
||||
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.Objects;
|
||||
import jakarta.persistence.Entity;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
@ -1,4 +1,4 @@
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations;
|
||||
package org.hibernate.orm.test.associations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
//tag::associations-any-property-example[]
|
||||
public interface Property<T> {
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import org.hibernate.annotations.Any;
|
||||
import org.hibernate.annotations.AnyDiscriminator;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import org.hibernate.annotations.Any;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.associations.any;
|
||||
package org.hibernate.orm.test.associations.any;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.batch;
|
||||
package org.hibernate.orm.test.batch;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityTransaction;
|
||||
@ -18,12 +18,12 @@
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
import org.hibernate.userguide.model.Account;
|
||||
import org.hibernate.userguide.model.Call;
|
||||
import org.hibernate.userguide.model.Partner;
|
||||
import org.hibernate.userguide.model.Payment;
|
||||
import org.hibernate.userguide.model.Person;
|
||||
import org.hibernate.userguide.model.Phone;
|
||||
import org.hibernate.testing.orm.domain.userguide.Account;
|
||||
import org.hibernate.testing.orm.domain.userguide.Call;
|
||||
import org.hibernate.testing.orm.domain.userguide.Partner;
|
||||
import org.hibernate.testing.orm.domain.userguide.Payment;
|
||||
import org.hibernate.testing.orm.domain.userguide.Person;
|
||||
import org.hibernate.testing.orm.domain.userguide.Phone;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class BatchTest extends BaseEntityManagerFunctionalTestCase {
|
||||
public class BatchTests extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.bootstrap;
|
||||
package org.hibernate.orm.test.bootstrap;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
@ -42,10 +42,10 @@
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor;
|
||||
import org.hibernate.orm.test.mapping.basic.bitset.BitSetType;
|
||||
import org.hibernate.orm.test.mapping.basic.bitset.BitSetUserType;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||
import org.hibernate.userguide.mapping.basic.bitset.BitSetType;
|
||||
import org.hibernate.userguide.mapping.basic.bitset.BitSetUserType;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -1,4 +1,10 @@
|
||||
package org.hibernate.userguide.events;
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.events;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import jakarta.persistence.MappedSuperclass;
|
@ -16,7 +16,7 @@
|
||||
<persistence-unit-defaults>
|
||||
<entity-listeners>
|
||||
<entity-listener
|
||||
class="org.hibernate.userguide.events.DefaultEntityListener">
|
||||
class="org.hibernate.orm.test.events.DefaultEntityListener">
|
||||
<pre-persist method-name="onPersist"/>
|
||||
<pre-update method-name="onUpdate"/>
|
||||
</entity-listener>
|
@ -1,4 +1,10 @@
|
||||
package org.hibernate.userguide.events;
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.events;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.events;
|
||||
package org.hibernate.orm.test.events;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ExcludeDefaultListeners;
|
||||
@ -35,7 +35,7 @@ protected Class<?>[] getAnnotatedClasses() {
|
||||
|
||||
@Override
|
||||
protected String[] getMappings() {
|
||||
return new String[] { "org/hibernate/userguide/events/DefaultEntityListener-orm.xml" };
|
||||
return new String[] { "org/hibernate/orm/test/events/DefaultEntityListener-orm.xml" };
|
||||
}
|
||||
|
||||
@Test
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.events;
|
||||
package org.hibernate.orm.test.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.events;
|
||||
package org.hibernate.orm.test.events;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
@ -1,4 +1,10 @@
|
||||
package org.hibernate.userguide.fetching;
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
@ -20,9 +26,9 @@
|
||||
import org.hibernate.graph.GraphParser;
|
||||
import org.hibernate.graph.EntityGraphs;
|
||||
import org.hibernate.graph.GraphSemantic;
|
||||
import org.hibernate.userguide.fetching.GraphFetchingTest.Department;
|
||||
import org.hibernate.userguide.fetching.GraphFetchingTest.Employee;
|
||||
import org.hibernate.userguide.fetching.GraphFetchingTest.Project;
|
||||
import org.hibernate.orm.test.fetching.GraphFetchingTest.Department;
|
||||
import org.hibernate.orm.test.fetching.GraphFetchingTest.Employee;
|
||||
import org.hibernate.orm.test.fetching.GraphFetchingTest.Project;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.junit.Assert;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.fetching;
|
||||
package org.hibernate.orm.test.fetching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityManager;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityManager;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.flush;
|
||||
package org.hibernate.orm.test.flush;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.hql;
|
||||
package org.hibernate.orm.test.hql;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
@ -4,7 +4,7 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.userguide.hql;
|
||||
package org.hibernate.orm.test.hql;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
@ -36,21 +36,22 @@
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.query.QueryProducer;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.userguide.model.Account;
|
||||
import org.hibernate.userguide.model.AddressType;
|
||||
import org.hibernate.userguide.model.Call;
|
||||
import org.hibernate.userguide.model.CreditCardPayment;
|
||||
import org.hibernate.userguide.model.Payment;
|
||||
import org.hibernate.userguide.model.Person;
|
||||
import org.hibernate.userguide.model.PersonNames;
|
||||
import org.hibernate.userguide.model.Phone;
|
||||
import org.hibernate.userguide.model.PhoneType;
|
||||
import org.hibernate.userguide.model.WireTransferPayment;
|
||||
import org.hibernate.testing.orm.domain.userguide.Account;
|
||||
import org.hibernate.testing.orm.domain.userguide.AddressType;
|
||||
import org.hibernate.testing.orm.domain.userguide.Call;
|
||||
import org.hibernate.testing.orm.domain.userguide.CreditCardPayment;
|
||||
import org.hibernate.testing.orm.domain.userguide.Payment;
|
||||
import org.hibernate.testing.orm.domain.userguide.Person;
|
||||
import org.hibernate.testing.orm.domain.userguide.PersonNames;
|
||||
import org.hibernate.testing.orm.domain.userguide.Phone;
|
||||
import org.hibernate.testing.orm.domain.userguide.PhoneType;
|
||||
import org.hibernate.testing.orm.domain.userguide.WireTransferPayment;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -280,7 +281,7 @@ public void hql_select_simplest_jpql_fqn_example() {
|
||||
//tag::hql-select-simplest-jpql-fqn-example[]
|
||||
List<Person> persons = entityManager.createQuery(
|
||||
"select p " +
|
||||
"from org.hibernate.userguide.model.Person p",
|
||||
"from org.hibernate.testing.orm.domain.userguide.Person p",
|
||||
Person.class)
|
||||
.getResultList();
|
||||
//end::hql-select-simplest-jpql-fqn-example[]
|
||||
@ -572,7 +573,7 @@ public void test_hql_collection_valued_associations_1() {
|
||||
.getResultList();
|
||||
//end::hql-collection-valued-associations[]
|
||||
assertEquals(1, phones.size());
|
||||
assertEquals("123-456-7890", phones.get(0).getNumber());
|
||||
assertEquals( "123-456-7890", phones.get( 0).getNumber());
|
||||
});
|
||||
|
||||
}
|
||||
@ -601,7 +602,7 @@ public void test_hql_collection_valued_associations_2() {
|
||||
.getResultList();
|
||||
//end::ejb-collection-valued-associations[]
|
||||
assertEquals(1, phones.size());
|
||||
assertEquals("123-456-7890", phones.get(0).getNumber());
|
||||
assertEquals( "123-456-7890", phones.get( 0).getNumber());
|
||||
});
|
||||
}
|
||||
|
||||
@ -2341,7 +2342,7 @@ public void test_hql_select_clause_dynamic_instantiation_example() {
|
||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||
//tag::hql-select-clause-dynamic-instantiation-example[]
|
||||
CallStatistics callStatistics = entityManager.createQuery(
|
||||
"select new org.hibernate.userguide.hql.CallStatistics(" +
|
||||
"select new org.hibernate.orm.test.hql.CallStatistics(" +
|
||||
" count(c), " +
|
||||
" sum(c.duration), " +
|
||||
" min(c.duration), " +
|
@ -4,17 +4,16 @@
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.userguide.hql;
|
||||
package org.hibernate.orm.test.hql;
|
||||
|
||||
import org.hibernate.testing.orm.domain.userguide.Account;
|
||||
import org.hibernate.testing.orm.domain.userguide.Call;
|
||||
import org.hibernate.testing.orm.domain.userguide.CreditCardPayment;
|
||||
import org.hibernate.testing.orm.domain.userguide.Person;
|
||||
import org.hibernate.testing.orm.domain.userguide.Phone;
|
||||
import org.hibernate.testing.orm.domain.userguide.WireTransferPayment;
|
||||
import org.hibernate.query.MutationQuery;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.query.SelectionQuery;
|
||||
import org.hibernate.userguide.model.Account;
|
||||
import org.hibernate.userguide.model.Call;
|
||||
import org.hibernate.userguide.model.CreditCardPayment;
|
||||
import org.hibernate.userguide.model.Person;
|
||||
import org.hibernate.userguide.model.Phone;
|
||||
import org.hibernate.userguide.model.WireTransferPayment;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user