[HHH-16122] Add test to reproduce problem

This commit is contained in:
Markus Heiden 2023-02-03 12:00:24 +01:00 committed by Christian Beikov
parent 63715770e9
commit aa76d057d9
1 changed files with 58 additions and 0 deletions

View File

@ -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<ConvertedValue, Long> {
@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<S extends 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<SubClass> {}
}