Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-206

enum in entity results in 'SQL Type not supported for Enum: 1' on mySQL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • EJB 3.0 RC1
    • EJB 3.0 Beta 1
    • None
    • None

      I've got the following entity bean:

      [code]
      @Entity
      @Table(name = "class")
      public class JClass implements java.io.Serializable {

      private static final long serialVersionUID = 1L;

      private Long key;
      private Long version;

      public void setKey(Long key)

      { this.key = key; }

      @Id(generate=GeneratorType.AUTO)
      @Column(name="id")
      public Long getKey()

      { return this.key; }

      @Version
      @Column(name="version")
      public Long getVersion()

      { return version; }

      public void setVersion(Long version)

      { this.version = version; }

      public void setScope(Scope scope)

      { this.scope = scope; }

      @Column(name="scope")
      public Scope getScope()

      { return scope; }

      }
      [/code]

      where Scope is an enum :

      [code]
      import java.io.Serializable;

      public enum Scope implements Serializable

      { PUBLIC, PROTECTED, PRIVATE; }

      [/code]

      My persistence.xml contains the following:

      [code]
      <entity-manager>
      <name>JavaLibraryEntityManager</name>
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/JavaLibraryds</jta-data-source>

      <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
      <property name="hibernate.hbm2ddl.auto" value="create"/>
      </properties>
      </entity-manager>
      [/code]

      When i deploy the software it creates the class table for me.
      According to chapter 2.2.2.1 (Hibernate annotations reference documentation) the database column can be a string type or an int type (storing the ordinal).

      In this case JBoss creates a int(11) column for me.
      But when i try to persist an object i get the following error:

      SQL Type not supported for Enums: 1

              rhn-engineering-ebernard Emmanuel Bernard
              ronaldmathies_jira Ronald Mathies (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: