1 Reply Latest reply on Jun 12, 2007 4:35 AM by Pete Muir

    How to map an array or a list of enums?

    Grant Rettke Novice

      Hi folks,

      In EJB 3.0 via Seam 1.2.1.GA we want to persist an entity with an array of enums.

      In the entity

      public UnderwritingConcernEnum[] getConcerns() {
       return concerns;
       }
      
       public void setConcerns(UnderwritingConcernEnum[] concerns) {
       this.concerns = concerns;
       }
      
      


      public enum UnderwritingConcernEnum {
      
       REINSURANCE("Reinsurance", "", "Re"),
       INSUREDS_REQUEST("Insured's Request", "", "IRt"),
       OLDER_ORNATE_STRUCTURE("Older Ornate Structure", "", "OOSe"),
       VALUATION("Valuation", "", "Vn"),
       LIABILTY_ACTIVITIES("Liability Exposures/Activities", "", "LAs"),
       OTHER("Other (Be Specific)", "", "Or");
      
       private final String label;
       private final String description;
       private final String value;
      
       UnderwritingConcernEnum(String label, String description, String value) {
       this.label = label;
       this.description = description;
       this.value = value;
       }
      
       public String getLabel() {
       return label;
       }
      
       public String getDescription() {
       return description;
       }
      
       public String getValue() {
       return value;
       }
      }
      


      We have tried using the ordinal enumeration attribute, and also removing it. Either way, this entity will no be persisted failing with the error.

      18:56:41,484 INFO [STDOUT] Hibernate: insert into Contact (CONTACT_NAME, CONTAC
      T_ROLE, CONTACT_EMAIL, CONTACT_PHONE, CONTACT_TITLE) values (?, ?, ?, ?, ?)
      18:56:41,515 INFO [STDOUT] Hibernate: insert into Account (priority, totalNumOf
      Buildings, totalBuildingValueFromInForceMP, CONTACT_ID, concerns, cmicAccountNum
      ber, expirationDate, acctName, acctAddress, acctCity, acctState, acctZip, todays
      Date, comments, requestedBy) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
      )
      18:56:41,531 ERROR [Priority1RequestActionMock] java.lang.ClassCastException: [L
      com.churchmutual.rms.enums.UnderwritingConcernEnum;