diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Address.java index acf335159a..c8983e4c81 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Address.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Address.java @@ -11,6 +11,7 @@ import java.io.Serializable; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import jakarta.persistence.ManyToOne; +import org.hibernate.annotations.Formula; /** * @author Emmanuel Bernard @@ -23,4 +24,7 @@ public class Address implements Serializable { Country country; @ManyToOne AddressType type; + + @Formula("1") + Integer formula; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/AddressBis.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/AddressBis.java new file mode 100644 index 0000000000..2a600d4b35 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/AddressBis.java @@ -0,0 +1,11 @@ +package org.hibernate.orm.test.bootstrap.binding.annotations.embedded; + +import jakarta.persistence.Embeddable; +import org.hibernate.annotations.Formula; + +@Embeddable +public class AddressBis { + + @Formula("2") + Integer formula; +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/EmbeddedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/EmbeddedTest.java index e9f55760bb..0cf5ee0d02 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/EmbeddedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/EmbeddedTest.java @@ -100,10 +100,13 @@ public class EmbeddedTest { assertNotNull( p ); assertNotNull( p.address ); assertEquals( "Springfield", p.address.city ); + assertEquals( (Integer) 1, p.address.formula ); + assertNotNull( p.address.country ); assertEquals( "DM", p.address.country.getIso2() ); assertNotNull( p.bornIn ); assertEquals( "US", p.bornIn.getIso2() ); + assertEquals( (Integer) 2, p.addressBis.formula ); } ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Person.java index 72a6b6f86e..4dc4704d57 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/annotations/embedded/Person.java @@ -33,6 +33,9 @@ public class Person implements Serializable { @Embedded Address address; + @Embedded + AddressBis addressBis; + @Embedded @AttributeOverrides( { @AttributeOverride(name = "iso2", column = @Column(name = "bornIso2")),