HHH-14703 Testcase showing that @Enumerated is picked up through implicit access type
This commit is contained in:
parent
3aafade866
commit
1f107e5a0a
|
@ -15,8 +15,7 @@ import org.hibernate.mapping.Property;
|
|||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -27,6 +26,8 @@ import jakarta.persistence.ElementCollection;
|
|||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
|
@ -37,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = { NestedEmbeddableDefaultAccessTests.MyEntity.class } )
|
||||
@SessionFactory( exportSchema = false )
|
||||
@JiraKey( "HHH-14703" )
|
||||
public class NestedEmbeddableDefaultAccessTests {
|
||||
@Test
|
||||
public void verifyEmbeddedMapping(DomainModelScope scope) {
|
||||
|
@ -47,7 +49,7 @@ public class NestedEmbeddableDefaultAccessTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-14063" )
|
||||
@JiraKey( "HHH-14063" )
|
||||
public void verifyElementCollectionMapping(DomainModelScope scope) {
|
||||
scope.withHierarchy( MyEntity.class, (descriptor) -> {
|
||||
final Property outerEmbeddedList = descriptor.getProperty( "outerEmbeddableList" );
|
||||
|
@ -62,11 +64,16 @@ public class NestedEmbeddableDefaultAccessTests {
|
|||
final Component nestedEmbeddable = (Component) nestedEmbedded.getValue();
|
||||
final Property nestedData = nestedEmbeddable.getProperty( "nestedData" );
|
||||
final BasicValue nestedDataMapping = (BasicValue) nestedData.getValue();
|
||||
final Property nestedEnum = nestedEmbeddable.getProperty( "nestedEnum" );
|
||||
final BasicValue nestedEnumMapping = (BasicValue) nestedEnum.getValue();
|
||||
|
||||
assertThat( outerDataMapping.getColumn().getText() ).isEqualTo( "outer_data" );
|
||||
assertThat( outerDataMapping.getJpaAttributeConverterDescriptor() ).isNotNull();
|
||||
|
||||
assertThat( nestedDataMapping.getColumn().getText() ).isEqualTo( "nested_data" );
|
||||
|
||||
// Check for HHH-14703
|
||||
assertThat( nestedEnumMapping.getEnumeratedType() ).isEqualTo( EnumType.STRING );
|
||||
}
|
||||
|
||||
@Entity( name = "MyEntity" )
|
||||
|
@ -126,5 +133,13 @@ public class NestedEmbeddableDefaultAccessTests {
|
|||
@Convert( converter = SillyConverter.class )
|
||||
@Column( name = "nested_data" )
|
||||
private String nestedData;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column( name = "nested_enum" )
|
||||
private MyEnum nestedEnum;
|
||||
}
|
||||
|
||||
public enum MyEnum {
|
||||
A,
|
||||
B
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue