4 Replies Latest reply on Oct 18, 2006 12:27 PM by peterj

    List of enum types is possible?

    ajaleo

      Hi all!

      I'd like to know if it's possible to have an entity with a field that is a list of a enumeration type. I've been using entities with enumerated fields but all of theme has a multiplicity of one.

      When I try to deploy I get this error:

       Reason: org.hibernate.MappingException: Could not determine type for: java.util.List, for columns: [org.hibernate.mapp
      ing.Column(usos)]
      


      My field is
      @Enumerated(EnumType.STRING)
       private List<UsoAeropuerto> usos;
      


      This is the UsoAeropuerto class
      ...
      public enum UsoAeropuerto {
       DEPORTIVO,
       CIVIL,
       MILITAR
      }
      
      


      Thanks a lot!

        • 1. Re: List of enum types is possible?
          copyrightwitness

          I don't know about the annotations but I am currently trying this...

          * @hibernate.list
          * cascade="all-delete-orphan"
          * lazy="true"
          * table="Options"
          * embed-xml="true"
          * @hibernate.list-index
          * column="listIndex"
          * @hibernate.key
          * column="ParentId"
          * @hibernate.element
          * ype="MyEnumUserType"
          * column="myEnum"

          which produced the following out of XDocLet:


          <list table="Options" lazy="true" cascade="all-delete-orphan" name="enumProperty" embed-xml="true">

          <list-index column="listIndex"/>



          The trick appears to be using 'element' rather than one-to-many or some such mapping. It certainly produces the correct DDL.

          Hope this helps,
          Barry

          • 2. Re: List of enum types is possible?
            copyrightwitness

            stupid forum! It thinks its html...argh.

            &lt;list table="Options" lazy="true" cascade="all-delete-orphan" name="myProperty" embed-xml="true"&gt;
            &lt;key column="myEnumFieldname"/&gt;
            &lt;list-index column="listIndex"/&gt;
            &lt;element type="MyEnumUserType" column="option"/&gt;
            &lt;/list&gt;

            That should work better!

            • 3. Re: List of enum types is possible?
              copyrightwitness

              oh pooo. You get the idea anyway!

              • 4. Re: List of enum types is possible?
                peterj

                To get the forum to display what you want, surround your code with [ code ] ... [ /code ] brackets (without the spaces). Or select your code and click on the Code button above the edit text box (don't use the "Instant Reply" text box, lcick on Post Reply instead).