-->
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.  [ 4 posts ] 
Author Message
 Post subject: how to map Enum property in hbm xml file???
PostPosted: Sun Jan 15, 2006 5:17 am 
Newbie

Joined: Mon Oct 10, 2005 1:55 pm
Posts: 12
Dear all
I am using the folowing C# code

public class test
{
.
.

enum eRType {CrossS, Scann, Refrac}
.
.
.

RModel RM = new RModel();
RM.RMType = eRType.Scann.ToString(); //the RMType is property

}

the class field containg the folowing code:
String RMType {get; set;}

the DB (oracle) i have
RMType Number(10) ;


what should i write in the hbm.xml file????
how should i mapp the enum???
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 15, 2006 9:55 pm 
Regular
Regular

Joined: Mon May 16, 2005 1:35 am
Posts: 67
Enums are supported natively by NHibernate. We just rely on NHibernate's use of reflection to infer the type of the enum property and map the property to an integer field in the database.


Top
 Profile  
 
 Post subject: Enum
PostPosted: Mon Jan 16, 2006 3:50 am 
Newbie

Joined: Mon Oct 10, 2005 1:55 pm
Posts: 12
so just simply map it with the property tag??? doesnt the reflection has any cost????
Is there any way that i can tell the data types?


Top
 Profile  
 
 Post subject: map enums
PostPosted: Mon Jan 16, 2006 11:03 am 
Newbie

Joined: Mon May 16, 2005 5:58 am
Posts: 11
Location: Galicia, Spain
you can try this:
class file:
Quote:
namespace Einsa.Nautilus.BOL
{
[Serializable]
public class Seccion : BOBase
{
[Serializable]
public enum TiposSeccion
{
Interior,
Cubierta,
Encarte
};

...

protected TiposSeccion tipoSeccion;
....
}



hbm file:
Quote:
...
<property name="tipoSeccion" column="tipoSeccion" type="Einsa.Nautilus.BOL.Seccion+TiposSeccion, Einsa.Nautilus.BOL" />
....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.