-->
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.  [ 5 posts ] 
Author Message
 Post subject: Enums with char values
PostPosted: Fri Jan 11, 2008 8:03 am 
Newbie

Joined: Mon Jan 07, 2008 8:26 pm
Posts: 7
Hi,

I am using NHibernate against an existing system which uses enums like this:

Code:
public enum Status
{
    Unallocated = 'U', Hold = 'H', Wait = 'W'
}


If I use EnumStringType, it just uses the full enum value (i.e. "Unallocated") rather than the character value. How can I remedy this?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 3:50 pm 
Newbie

Joined: Sat Jan 12, 2008 3:40 pm
Posts: 2
If someone can definitely say that this is a bug/missing feature I can probably fix it this weekend.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 3:53 pm 
Newbie

Joined: Mon Jan 07, 2008 8:26 pm
Posts: 7
As far as I can find it has been raised multiple times without a real conclusion. I think I have solved it by creating a UserType, but the UserType is three times more code than the enum itself, though it could be made generic. It would definitely be better to have this functionality out of the box.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 11:25 pm 
Newbie

Joined: Sat Jan 12, 2008 3:40 pm
Posts: 2
http://jira.nhibernate.org/browse/NH-1248

Works just like EnumStringType except it persists the underlying char value. C# doesn't support enums with type char so technically its all Int32 under the hood but it still has the desired effect.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 13, 2008 7:58 am 
Newbie

Joined: Mon Jan 07, 2008 8:26 pm
Posts: 7
Brilliant, thank you!


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