diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Address.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Address.java new file mode 100644 index 0000000000..89853206cc --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Address.java @@ -0,0 +1,7 @@ +package org.hibernate.jpamodelgen.test.records; + +import jakarta.persistence.Embeddable; + +@Embeddable +public record Address(String street, String city, String postalCode) { +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Author.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Author.java new file mode 100644 index 0000000000..2a95f38558 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Author.java @@ -0,0 +1,53 @@ +package org.hibernate.jpamodelgen.test.records; + +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +@Entity +public class Author { + + @Id + @GeneratedValue + private Long id; + + @Embedded + private Address address; + + private String firstName; + + private String lastName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Java14RecordsTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Java14RecordsTest.java new file mode 100644 index 0000000000..c978f82763 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/records/Java14RecordsTest.java @@ -0,0 +1,19 @@ +package org.hibernate.jpamodelgen.test.records; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import org.hibernate.jpamodelgen.test.util.TestForIssue; +import org.hibernate.jpamodelgen.test.util.WithClasses; +import org.junit.Test; + +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor; + +public class Java14RecordsTest extends CompilationTest { + + @Test + @TestForIssue(jiraKey = "HHH-16261") + @WithClasses({Address.class, Author.class}) + public void testEmbeddableRecordProperty() { + assertMetamodelClassGeneratedFor(Address.class); + assertMetamodelClassGeneratedFor(Author.class); + } +}