HHH-14885 - New composite user-type
`@EmbeddableInstantiatorRegistration`
This commit is contained in:
parent
61d178ef1b
commit
9137b9e79a
|
@ -262,8 +262,9 @@ values follow Java Bean conventions - e.g. a struct or Java 15 record.
|
|||
|
||||
Hibernate allows the use of a custom instantiator for creating the embeddable instances through the
|
||||
`org.hibernate.metamodel.spi.EmbeddableInstantiator` contract. The custom instantiator is specified
|
||||
using the `@org.hibernate.annotations.EmbeddableInstantiator` annotation. Which can either be defined
|
||||
on the property:
|
||||
using the `@org.hibernate.annotations.EmbeddableInstantiator` annotation.
|
||||
|
||||
A custom instantiator can be defined on the property:
|
||||
|
||||
[[embeddable-instantiator-property-ex]]
|
||||
.`@EmbeddableInstantiator` on attribute
|
||||
|
@ -271,6 +272,7 @@ on the property:
|
|||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{instantiatorTestDir}/embedded/Name.java[tags=embeddable-instantiator-property]
|
||||
|
||||
include::{instantiatorTestDir}/embedded/Person.java[tags=embeddable-instantiator-property]
|
||||
----
|
||||
====
|
||||
|
@ -283,12 +285,13 @@ or on the embeddable class:
|
|||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{instantiatorTestDir}/embeddable/Name.java[tags=embeddable-instantiator-class]
|
||||
|
||||
include::{instantiatorTestDir}/embeddable/Person.java[tags=embeddable-instantiator-class]
|
||||
----
|
||||
====
|
||||
|
||||
|
||||
Additionally, instantiators can be registered:
|
||||
or registered:
|
||||
|
||||
[[embeddable-instantiator-registration-ex]]
|
||||
.`@EmbeddableInstantiatorRegistration`
|
||||
|
@ -296,6 +299,7 @@ Additionally, instantiators can be registered:
|
|||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{instantiatorTestDir}/registered/Name.java[tags=embeddable-instantiator-registration]
|
||||
|
||||
include::{instantiatorTestDir}/registered/Person.java[tags=embeddable-instantiator-registration]
|
||||
----
|
||||
====
|
||||
|
|
|
@ -17,9 +17,9 @@ import jakarta.persistence.Entity;
|
|||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "persons")
|
||||
//tag::embeddable-instantiator-class[]
|
||||
@Entity
|
||||
public class Person {
|
||||
@Id
|
||||
public Integer id;
|
||||
|
|
|
@ -20,9 +20,9 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.Table;
|
||||
|
||||
|
||||
//tag::embeddable-instantiator-property[]
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "persons")
|
||||
//tag::embeddable-instantiator-property[]
|
||||
@Entity
|
||||
public class Person {
|
||||
@Id
|
||||
public Integer id;
|
||||
|
|
|
@ -20,9 +20,9 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.Table;
|
||||
|
||||
|
||||
//tag::embeddable-instantiator-registration[]
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "persons")
|
||||
//tag::embeddable-instantiator-registration[]
|
||||
@Entity
|
||||
@EmbeddableInstantiatorRegistration( embeddableClass = Name.class, instantiator = NameInstantiator.class )
|
||||
public class Person {
|
||||
@Id
|
||||
|
|
Loading…
Reference in New Issue