From 9b59f7c1b6b9748c40ebc997dc73e64bd575e1fd Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 1 Feb 2023 17:38:10 +0100 Subject: [PATCH] HHH-15970 Add test for issue --- .../MappedSuperclassAndGenericsTest.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/MappedSuperclassAndGenericsTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/MappedSuperclassAndGenericsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/MappedSuperclassAndGenericsTest.java new file mode 100644 index 0000000000..08778bb349 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/MappedSuperclassAndGenericsTest.java @@ -0,0 +1,90 @@ +package org.hibernate.orm.test.annotations.generics; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; + +import org.junit.jupiter.api.Test; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; + +@DomainModel( + annotatedClasses = { + MappedSuperclassAndGenericsTest.RawEntity.class, + MappedSuperclassAndGenericsTest.LongEntity.class + } +) +@SessionFactory +@TestForIssue( jiraKey = "HHH-15970") +public class MappedSuperclassAndGenericsTest { + + public enum MyEnum { + A, B + } + + @Test + public void testIt(SessionFactoryScope scope){ + scope.inTransaction( + session -> { + + } + ); + } + + @MappedSuperclass + public static abstract class ParameterizedParent { + + @Enumerated(EnumType.STRING) + private MyEnum myEnum; + + public MyEnum getMyEnum() { + return myEnum; + } + + public void setMyEnum(MyEnum myEnum) { + this.myEnum = myEnum; + } + + } + + @Entity(name = "RawEntity") + public static class RawEntity extends ParameterizedParent { + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + @Column(name = "id", nullable = false) + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + } + + @Entity(name = "LongEntity") + public static class LongEntity extends ParameterizedParent { + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + @Column(name = "id", nullable = false) + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + } + +}