|
4 | 4 | :core-project-dir: {root-project-dir}/hibernate-core
|
5 | 5 | :core-test-base: {core-project-dir}/src/test/java/org/hibernate/orm/test
|
6 | 6 | :example-dir-identifier: {core-test-base}/mapping/identifier
|
| 7 | +:example-dir-generated: {core-test-base}/mapping/generated |
7 | 8 | :example-dir-associations: {core-test-base}/associations
|
8 | 9 | :jpaJavadocUrl: https://javadoc.io/doc/jakarta.persistence/jakarta.persistence-api/latest/jakarta.persistence
|
9 | 10 | :extrasdir: extras
|
@@ -392,6 +393,24 @@ include::{example-dir-identifier}/SequenceGeneratorConfiguredTest.java[tag=ident
|
392 | 393 | Again the mapping specifies `explicit_product_sequence` as the physical sequence name, but it also specifies an
|
393 | 394 | explicit allocation-size ("increment by").
|
394 | 395 |
|
| 396 | +The scope of the generator name can be controlled with the <<settings-hibernate.jpa.compliance.global_id_generators,`hibernate.jpa.compliance.global_id_generators`>> |
| 397 | +configuration setting. With <<settings-compliance,JPA compliance>> enabled, the name scope is global i.e. |
| 398 | +there may not be two generator definitions with the same name. Historically, Hibernate ORM used a local scope i.e. |
| 399 | +every managed type may have a generator with the same name, preferring the "local" definition over a more distant one. |
| 400 | +This behavior allows to model e.g. a mapped superclass with a generator that should apply to subclasses by default, |
| 401 | +yet allow an entity subclass to choose a custom generator by simply specifying the same generator name. |
| 402 | + |
| 403 | +[[identifiers-generators-sequence-override]] |
| 404 | +.Sequence override |
| 405 | +==== |
| 406 | +[source,java] |
| 407 | +---- |
| 408 | +include::{example-dir-generated}/override/SequenceGeneratorOverrideTest.java[tag=identifiers-generators-sequence-override-example, indent=0] |
| 409 | +---- |
| 410 | +==== |
| 411 | + |
| 412 | +In this case, `base_sequence` will be used when a `Entity1` is persisted, |
| 413 | +whereas for persists of a `Entity2`, Hibernate ORM will use `sub_sequence`. |
395 | 414 |
|
396 | 415 | [[identifiers-generators-identity]]
|
397 | 416 | ==== Using IDENTITY columns
|
|
0 commit comments