[JIRA] (HHH-16838) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL
by Hyeonmin Park (JIRA)
Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzI2MzQ2ZDRk... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYzI2Mz... ) HHH-16838 ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYzI2Mz... ) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYzI2Mz... )
Change By: Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The fix for [HHH-16498]([https://github.com/hibernate/hibernate-orm/pull/6539|https://... seems to be making {{columnDefinition}} value ignored.
h2. Reproducer
{code:java}package org.hibernate.orm.test.schemavalidation;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static jakarta.persistence.GenerationType.IDENTITY;
@JiraKey("HHH-16838")
@RequiresDialect(MySQLDialect.class)
public class MySqlExistingCharAsJavaEnumColumnValidationTest extends BaseCoreFunctionalTestCase {
private StandardServiceRegistry ssr;
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { EntityE.class };
}
@Before
public void setUp() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE IF EXISTS en CASCADE" ).executeUpdate();
session.createNativeQuery(
"CREATE TABLE en (id INTEGER NOT NULL AUTO_INCREMENT"
+ ", sign_position_as_varchar varchar(20)"
+ ", sign_position_as_char char(20)"
+ ", PRIMARY KEY (id))" )
.executeUpdate();
} );
}
@After
public void tearDown() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE en CASCADE" ).executeUpdate();
} );
}
@Test
public void testSynonymUsingGroupedSchemaValidator() {
ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.HBM2DDL_AUTO, "validate" )
.build();
try {
final MetadataSources metadataSources = new MetadataSources( ssr );
metadataSources.addAnnotatedClass( EntityE.class );
new SchemaValidator().validate( metadataSources.buildMetadata() );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
@Entity(name = "en")
@Table(name = "en")
public static class EntityE {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Integer id;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_varchar")
private SignPosition signPositionAsVarchar;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_char", columnDefinition = "char(20)")
private SignPosition signPositionAsChar;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public SignPosition getSignPositionAsVarchar() {
return signPositionAsVarchar;
}
public void setSignPositionAsVarchar(SignPosition signPositionAsVarchar) {
this.signPositionAsVarchar = signPositionAsVarchar;
}
public SignPosition getSignPositionAsChar() {
return signPositionAsChar;
}
public void setSignPositionAsChar(SignPosition signPositionAsChar) {
this.signPositionAsChar = signPositionAsChar;
}
}
public enum SignPosition {
AFTER_NO_SPACE, AFTER_WITH_SPACE, BEFORE_NO_SPACE, BEFORE_WITH_SPACE
}
}{code}
h2. Expected result
Since {{signPositionAsChar}} is both declared as char(20) in the SQL query and the {{columnDefinition}}, the test should be passed.
h2. Actual result
{quote}Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en]; found [char (Types#CHAR)], but expecting [char(20) (Types#VARCHAR)]{quote}
h2. Comments
* {{ColumnDefinitions.getSqlType(Column, Metadata)}} returns {{enum ('AFTER_NO_SPACE','AFTER_WITH_SPACE','BEFORE_NO_SPACE','BEFORE_WITH_SPACE')}} and {{column.getSqlType( metadata )}} properly returns {{char(20)}}. I think there should exist a check for the pre-configured {{sqlType}}.
* The message of {{SchemaManagementException}} is not matched to {{ColumnDefinitions.getSqlType(Column, Metadata)}} but since it’s a private method, {{AbstractSchemaValidator.validateColumnType}} cannot know what’s going on exactly.
* Maybe it’s related to [https://hibernate.atlassian.net/browse/HHH-16670|https://hibernate.atlass...] or [https://hibernate.atlassian.net/browse/HHH-16694|https://hibernate.atlass...] but they say that those are occurring prior to 6.2.5.
I’ve confirmed this issue is not affected until 6.2.2 (via Spring Boot 3.1.0), also 6.2.3 nor 6.2.4 (checked manually by changing {{ext['hibernate.version']}}) so it can be not related, though.
( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:d138f7b )
1 year, 6 months
[JIRA] (HHH-16838) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL
by Hyeonmin Park (JIRA)
Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTI1Yzk5YTRh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTI1Yz... ) HHH-16838 ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTI1Yz... ) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTI1Yz... )
Change By: Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The fix for [HHH-16498]([https://github.com/hibernate/hibernate-orm/pull/6539|https://... seems to be making {{columnDefinition}} value ignored.
h2. Reproducer
{code:java}package org.hibernate.orm.test.schemavalidation;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static jakarta.persistence.GenerationType.IDENTITY;
@JiraKey("HHH-16838")
@RequiresDialect(MySQLDialect.class)
public class MySqlExistingCharAsJavaEnumColumnValidationTest extends BaseCoreFunctionalTestCase {
private StandardServiceRegistry ssr;
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { EntityE.class };
}
@Before
public void setUp() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE IF EXISTS en CASCADE" ).executeUpdate();
session.createNativeQuery(
"CREATE TABLE en (id INTEGER NOT NULL AUTO_INCREMENT"
+ ", sign_position_as_varchar varchar(20)"
+ ", sign_position_as_char char(20)"
+ ", PRIMARY KEY (id))" )
.executeUpdate();
} );
}
@After
public void tearDown() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE en CASCADE" ).executeUpdate();
} );
}
@Test
public void testSynonymUsingGroupedSchemaValidator() {
ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.HBM2DDL_AUTO, "validate" )
.build();
try {
final MetadataSources metadataSources = new MetadataSources( ssr );
metadataSources.addAnnotatedClass( EntityE.class );
new SchemaValidator().validate( metadataSources.buildMetadata() );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
@Entity(name = "en")
@Table(name = "en")
public static class EntityE {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Integer id;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_varchar")
private SignPosition signPositionAsVarchar;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_char", columnDefinition = "char(20)")
private SignPosition signPositionAsChar;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public SignPosition getSignPositionAsVarchar() {
return signPositionAsVarchar;
}
public void setSignPositionAsVarchar(SignPosition signPositionAsVarchar) {
this.signPositionAsVarchar = signPositionAsVarchar;
}
public SignPosition getSignPositionAsChar() {
return signPositionAsChar;
}
public void setSignPositionAsChar(SignPosition signPositionAsChar) {
this.signPositionAsChar = signPositionAsChar;
}
}
public enum SignPosition {
AFTER_NO_SPACE, AFTER_WITH_SPACE, BEFORE_NO_SPACE, BEFORE_WITH_SPACE
}
}{code}
h2. Expected result
Since {{signPositionAsChar}} is both declared as char(20) in the SQL query and the {{columnDefinition}}, the test should be passed.
h2. Actual result
{quote}Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en]; found [char (Types#CHAR)], but expecting [char(20) (Types#VARCHAR)]{quote}
h2. Comments
* {{ColumnDefinitions.getSqlType(Column, Metadata)}} returns {{enum ('AFTER_NO_SPACE','AFTER_WITH_SPACE','BEFORE_NO_SPACE','BEFORE_WITH_SPACE')}} and {{column.getSqlType( metadata )}} properly returns {{char(20)}}. I think there should exist a check for the pre-configured {{sqlType}}.
* The message of {{SchemaManagementException}} is not matched to {{ColumnDefinitions.getSqlType(Column, Metadata)}} but since it’s a private method, {{AbstractSchemaValidator.validateColumnType}} cannot know what’s going on exactly.
( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:d138f7b )
1 year, 6 months
[JIRA] (HHH-16838) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL
by Hyeonmin Park (JIRA)
Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmFkMmVkMGQ3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiMmFkMm... ) HHH-16838 ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiMmFkMm... ) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiMmFkMm... )
Change By: Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The fix for [ HHH-16498 ] ( [ https://github.com/hibernate/hibernate-orm/pull/6539 |https://github.com/hibernate/hibernate-orm/pull/6539|smart-link] ) seems to be making ` {{ columnDefinition ` }} value ignored.
h2. Reproducer
{code:java}
package org.hibernate.orm.test.schemavalidation;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static jakarta.persistence.GenerationType.IDENTITY;
@JiraKey("HHH- 99999 16838 ")
@RequiresDialect(MySQLDialect.class)
public class MySqlExistingCharAsJavaEnumColumnValidationTest extends BaseCoreFunctionalTestCase {
private StandardServiceRegistry ssr;
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { EntityE.class };
}
@Before
public void setUp() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE IF EXISTS en CASCADE" ).executeUpdate();
session.createNativeQuery(
"CREATE TABLE en (id INTEGER NOT NULL AUTO_INCREMENT"
+ ", sign_position_as_varchar varchar(20)"
+ ", sign_position_as_char char(20)"
+ ", PRIMARY KEY (id))" )
.executeUpdate();
} );
}
@After
public void tearDown() {
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE en CASCADE" ).executeUpdate();
} );
}
@Test
public void testSynonymUsingGroupedSchemaValidator() {
ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.HBM2DDL_AUTO, "validate" )
.build();
try {
final MetadataSources metadataSources = new MetadataSources( ssr );
metadataSources.addAnnotatedClass( EntityE.class );
new SchemaValidator().validate( metadataSources.buildMetadata() );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
@Entity(name = "en")
@Table(name = "en")
public static class EntityE {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Integer id;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_varchar")
private SignPosition signPositionAsVarchar;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_char", columnDefinition = "char(20)")
private SignPosition signPositionAsChar;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public SignPosition getSignPositionAsVarchar() {
return signPositionAsVarchar;
}
public void setSignPositionAsVarchar(SignPosition signPositionAsVarchar) {
this.signPositionAsVarchar = signPositionAsVarchar;
}
public SignPosition getSignPositionAsChar() {
return signPositionAsChar;
}
public void setSignPositionAsChar(SignPosition signPositionAsChar) {
this.signPositionAsChar = signPositionAsChar;
}
}
public enum SignPosition {
AFTER_NO_SPACE, AFTER_WITH_SPACE, BEFORE_NO_SPACE, BEFORE_WITH_SPACE
}
}
{code}
h2. Expected result
Since ` {{ signPositionAsChar ` }} is both declared as char(20) in the SQL query and the ` {{ columnDefinition ` }} , the test should be passed.
h2. Actual result
> {quote} Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en]; found [char (Types#CHAR)], but expecting [char(20) (Types#VARCHAR)] {quote}
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en]; found [char (Types#CHAR)], but expecting [char(20) (Types#VARCHAR)]
h2. Comments
` * {{ ColumnDefinitions.getSqlType(Column, Metadata) ` }} returns ` {{ enum ('AFTER_NO_SPACE','AFTER_WITH_SPACE','BEFORE_NO_SPACE','BEFORE_WITH_SPACE') ` }} and ` {{ column.getSqlType( metadata ) ` }} properly returns ` {{ char(20) ` }}. I think there should exist a check for the pre-configured {{ sqlType }}.
*
( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:d138f7b )
1 year, 6 months
[JIRA] (HHH-16838) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL
by Hyeonmin Park (JIRA)
Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTBmMjg2ZTRj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTBmMj... ) HHH-16838 ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTBmMj... ) Cannot use columnDefinition CHAR overriding for enumerated column on MySQL ( https://hibernate.atlassian.net/browse/HHH-16838?atlOrigin=eyJpIjoiYTBmMj... )
Issue Type: Bug Affects Versions: 6.2.5 Assignee: Unassigned Components: hibernate-core Created: 23/Jun/2023 04:09 AM Environment: Hibernate 6.2.5 (via Spring Boot 3.1.1), JVM 17, MySQL 5.7.27 Priority: Blocker Reporter: Hyeonmin Park ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The fix for HHH-16498 ( https://hibernate.atlassian.net/browse/HHH-16498 ) Closed ( https://github.com/hibernate/hibernate-orm/pull/6539 ) seems to be making `columnDefinition` value ignored.
----------
Reproducer
----------
package org.hibernate.orm.test.schemavalidation;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.transaction.TransactionUtil;
import org.hibernate.tool.hbm2ddl.SchemaValidator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static jakarta.persistence.GenerationType.IDENTITY;
@JiraKey( "HHH-99999" )
@RequiresDialect(MySQLDialect.class)
public class MySqlExistingCharAsJavaEnumColumnValidationTest extends BaseCoreFunctionalTestCase {
private StandardServiceRegistry ssr;
@Override
protected Class <?>[] getAnnotatedClasses() {
return new Class <?>[] { EntityE.class };
}
@Before
public void setUp() {
TransactionUtil.doInHibernate( this ::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE IF EXISTS en CASCADE" ).executeUpdate();
session.createNativeQuery(
"CREATE TABLE en (id INTEGER NOT NULL AUTO_INCREMENT"
+ ", sign_position_as_varchar varchar(20)"
+ ", sign_position_as_char char (20)"
+ ", PRIMARY KEY (id))" )
.executeUpdate();
} );
}
@After
public void tearDown() {
TransactionUtil.doInHibernate( this ::sessionFactory, session -> {
session.createNativeQuery( "DROP TABLE en CASCADE" ).executeUpdate();
} );
}
@Test
public void testSynonymUsingGroupedSchemaValidator() {
ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.HBM2DDL_AUTO, "validate" )
.build();
try {
final MetadataSources metadataSources = new MetadataSources( ssr );
metadataSources.addAnnotatedClass( EntityE.class );
new SchemaValidator().validate( metadataSources.buildMetadata() );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
@Entity(name = "en" )
@Table(name = "en" )
public static class EntityE {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id" , nullable = false , updatable = false )
private Integer id;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_varchar" )
private SignPosition signPositionAsVarchar;
@Enumerated(EnumType.STRING)
@Column(name = "sign_position_as_char" , columnDefinition = " char (20)" )
private SignPosition signPositionAsChar;
public Integer getId() {
return id;
}
public void setId( Integer id) {
this.id = id;
}
public SignPosition getSignPositionAsVarchar() {
return signPositionAsVarchar;
}
public void setSignPositionAsVarchar(SignPosition signPositionAsVarchar) {
this.signPositionAsVarchar = signPositionAsVarchar;
}
public SignPosition getSignPositionAsChar() {
return signPositionAsChar;
}
public void setSignPositionAsChar(SignPosition signPositionAsChar) {
this.signPositionAsChar = signPositionAsChar;
}
}
public enum SignPosition {
AFTER_NO_SPACE, AFTER_WITH_SPACE, BEFORE_NO_SPACE, BEFORE_WITH_SPACE
}
}
---------------
Expected result
---------------
Since `signPositionAsChar` is both declared as char(20) in the SQL query and the `columnDefinition`, the test should be passed.
-------------
Actual result
-------------
> Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en] ; found char (Types#CHAR) ( #CHAR) ) , but expecting char(20) (Types#VARCHAR) ( #VARCHAR) )
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [sign_position_as_char] in table [en] ; found char (Types#CHAR) ( #CHAR) ) , but expecting char(20) (Types#VARCHAR) ( #VARCHAR) )
--------
Comments
--------
`ColumnDefinitions.getSqlType(Column, Metadata)` returns `enum ('AFTER_NO_SPACE','AFTER_WITH_SPACE','BEFORE_NO_SPACE','BEFORE_WITH_SPACE')` and `column.getSqlType( metadata )` properly returns `char(20)`. I think there should exist a check for the pre-configured sqlType.
( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16838#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:d138f7b )
1 year, 6 months