From a7448bb15a016cf6310a26c812c2056a48f49429 Mon Sep 17 00:00:00 2001 From: Markus Heiden Date: Fri, 3 Feb 2023 12:00:24 +0100 Subject: [PATCH] [HHH-16122] Add test to reproduce problem --- .../orm/test/annotations/HHH16122Test.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/annotations/HHH16122Test.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/HHH16122Test.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/HHH16122Test.java new file mode 100644 index 0000000000..8a1e96fd2c --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/HHH16122Test.java @@ -0,0 +1,58 @@ +package org.hibernate.orm.test.annotations; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; +import org.hibernate.testing.TestForIssue; +import org.junit.Test; + +@TestForIssue( jiraKey = "HHH-16122" ) +public class HHH16122Test extends BaseEntityManagerFunctionalTestCase { + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { ValueConverter.class, SuperClass.class, SubClass.class }; + } + + @Test + public void testGenericSuperClassWithConverter() { + // The test is successful if the entity manager factory can be built. + } + + public static class ConvertedValue { + public final long value; + public ConvertedValue(long value) { + this.value = value; + } + } + + @Converter(autoApply = true) + public static class ValueConverter implements AttributeConverter { + @Override + public Long convertToDatabaseColumn( ConvertedValue value ) { + return value.value; + } + @Override + public ConvertedValue convertToEntityAttribute( Long value ) { + return new ConvertedValue(value); + } + } + + @MappedSuperclass + public static abstract class SuperClass { + @Id + private String id; + public ConvertedValue convertedValue = new ConvertedValue( 1 ); + public ConvertedValue getConvertedValue() { + return convertedValue; + } + public void setConvertedValue(ConvertedValue convertedValue) { + this.convertedValue = convertedValue; + } + } + + @Entity(name = "SubClass") + public static class SubClass extends SuperClass {} +}