0 Replies Latest reply on Apr 25, 2006 4:56 PM by Walter Herbert

    EJB3 MySQL & ENUM Problem

    Walter Herbert Newbie

      Hi,

      My Problem is, that i cannot persist the Entity's. But if i make an entry into the DB and just read it then it works.

      ejb:

      
      @Entity
      @Table(name = "userproperties")
      @NamedQueries(...)
      public class WM_UserProperties implements Serializable{
      ...
      public enum Ask4Masterpassword {NEVER,EVERY_TIME_IS_NEEDED,ONCE_PER_SESSION};
      
      private Ask4Masterpassword ask4Masterpassword;
      
      @Column(name="wm2_up_ask4masterpassword")
       public Ask4Masterpassword getAsk4Masterpassword() {
       return ask4Masterpassword;
       }
      ...
      }
      


      MySQL Table
      ...
      ask4masterpassword enum('NEVER','EVERY_TIME_IS_NEEDED','ONCE_PER_SESSION') latin1_swedish_ci
      ...
      



      errormsg:

      22:48:32,156 INFO [STDOUT] [WM_UserSessionBean] persist now: UserPropertiesId: null
      userID: 5337
      getMaxMailBoxAccounts: 3
      Ask4Password: NEVER
      22:48:32,171 WARN [JDBCExceptionReporter] SQL Error: 1265, SQLState: 01000
      22:48:32,171 ERROR [JDBCExceptionReporter] Data truncated for column 'wm2_up_ask4masterpassword' at row 1
      22:48:32,171 INFO [STDOUT] [WM_UserSessionBean] Exception: public <T> T persist(T o)
      22:48:32,171 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [wm2.ejb.entity.WM_UserProperties]
      22:48:32,171 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:562)
      22:48:32,171 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:193)
      22:48:32,171 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:175)