[HHH-16122] Add test to reproduce problem
This commit is contained in:
parent
63715770e9
commit
aa76d057d9
|
@ -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> {}
|
||||
}
|
Loading…
Reference in New Issue