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: Read hbm information?
PostPosted: Wed Jul 18, 2007 12:22 pm 
Newbie

Joined: Thu Jun 21, 2007 8:44 am
Posts: 4
I would like to extract mapping file information to use on my form.

E.g.
<property name="reference" column="Reference" type="String" length="50"/>

I would like to extract this information so I can set my asp.net validator to only allow a maximum of 50 characters in a text box.

Something like:

FieldInfo NHibernate.GetInfo(classType, classFieldname);

would be nice.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 18, 2007 2:50 pm 
Newbie

Joined: Wed Jul 04, 2007 5:31 pm
Posts: 17
Sorry for answering with question but how do you plan to validate more complex rules (rules that include two or more database columns)?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 3:56 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 10:32 am
Posts: 34
Here is a code snippet we use to find the "NHibernate type" of a property; you certainly can find other information about this when you navigate the IClassMetadata and related classes (any tool that has auto completion with documentation tooltips is helpful here - VisualStudio, ReSharper, ...).

Code:
IClassMetadata metaData = _session.SessionFactory.GetClassMetadata(persistentClass);

return propertyName == metaData.IdentifierPropertyName
   ? metaData.IdentifierType
   : metaData.GetPropertyType(propertyName);


Regards
Harald


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.