-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: [Solved] Enum mapping
PostPosted: Fri Jun 02, 2006 1:22 am 
Beginner
Beginner

Joined: Tue May 23, 2006 12:53 am
Posts: 34
How do I map enumeration type, say I have a Section class that has Category which is an enum. Section code is something like
Code:
/*
* Section.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/

using System;

namespace Agta.ManilaBulletin.Data
{
   /// <summary>
   ///
   /// </summary>
   public class Section : Observable
   {
      private int id;
      private string title;
      private string description;
      private bool isInactive;
      private Category category;

//      private static Section instance = new Section();
//      public static Section Instance
//      {
//         get { return instance; }
//      }

      public Section(int id, string title, string description,
         bool isInactive, Category category)
      {
         this.Id = id;
         this.Title = title;
         this.Description = description;
         this.IsInactive = isInactive;
         this.Category = category;
      }

      public Section(int id) : this (id, "", "", false, Category.NewsAndFeatures) {}

      /// <summary>
      /// Creates a new instance of Section.
      /// </summary>
      public Section() : this (0) {}

      public int Id
      {
         get { return id; }
         set { id = value; }
      }

      public string Title
      {
         get { return title; }
         set { title = value; }
      }

      public string Description
      {
         get { return description; }
         set { description = value; }
      }

      public bool IsInactive
      {
         get { return isInactive; }
         set { isInactive = value; }
      }

      public Category Category
      {
         get { return category; }
         set { category = value; }
      }
   }
}
and my Enum Category
Code:
/*
* Category.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/

using System;

namespace Agta.ManilaBulletin.Data
{
   /// <summary>
   ///
   /// </summary>
   public enum Category
   {
      NewsAndFeatures,
      KababayanEdition,
      Hometown,
      OwningAHome
   }
}
and my Section.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="Agta.ManilaBulletin.Data" assembly="webartiData">
   <class name="Section" table="Sections">
      <id name="Id" column="SectionId" type="Int32">
         <generator class="identity"/>
      </id>
      <property name="Title" column="Title" type="String"/>
      <property name="Description" column="Description" type="String"/>      
      <property name="IsInactive" column="IsInactive" type="Boolean"/>
      <!-- <TODO> for Category enum... -->
   </class>
</hibernate-mapping>
Any help? Thanks in advance!


Last edited by nebulom on Fri Jun 02, 2006 5:25 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 4:32 am 
Newbie

Joined: Wed Jan 25, 2006 10:53 pm
Posts: 9
Just like a type....fully qualified type name.

<property name="m_Status" column="Status" type="Igs.Objects.SiteUserStatus, Igs.Objects" access="field" />


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 5:24 am 
Beginner
Beginner

Joined: Tue May 23, 2006 12:53 am
Posts: 34
Thanks. I thought of another type but I it's just the same as normal types. Thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.