[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2354) Schema validation too rigid for MySql enums
Alex Fuller (JIRA)
noreply at atlassian.com
Tue Jan 20 11:18:39 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32162#action_32162 ]
Alex Fuller commented on HHH-2354:
----------------------------------
Another workaround if you're using JPA annotations is to add an @Column(columnDefinition="enum('val1', 'val2'... 'valN')") annotation. At least you can leave schema validation on. However this will not help if you are swapping between MySQL and another database for dev/test etc.
> Schema validation too rigid for MySql enums
> -------------------------------------------
>
> Key: HHH-2354
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2354
> Project: Hibernate Core
> Issue Type: Bug
> Components: metamodel
> Environment: jboss-seam-1.1.0.GA, MySQL 5
> Reporter: Zeljko Trogrlic
>
> Enum column type in MySQL is handled as CHAR in their JDBC driver and should be mapped to String Java type.
> However, Hibernate expects varchar(n) and fails to do the validation.
> This is how DatabaseMetaData.getColumns describes it:
> DATA_TYPE=1
> TYPE_NAME=enum
> Note that although TYPE_NAME is enum, DATA_TYPE represents CHAR.
> Hibernate reports following exception:
> 13:49:31,397 INFO [TableMetadata] table found: configuration.userdb_domain_acl
> 13:49:31,397 INFO [TableMetadata] columns: [id, enabled, tablename, domain]
> 13:49:31,397 WARN [ServiceController] Problem starting service persistence.units:ear=msmgui.ear,unitName=msmgui
> javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: enabled, expected: varchar(
> 2)
> at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
> at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
> at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> Validation should be fixed/relaxed to avoid this problem.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list