-->
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.  [ 2 posts ] 
Author Message
 Post subject: Read XML Configuration at RunTime
PostPosted: Tue Jan 31, 2006 5:33 pm 
Regular
Regular

Joined: Fri Jan 27, 2006 2:32 pm
Posts: 102
Location: California, USA
How would you go about reading the hbm.xml configuration files at runtime. I don't want to actually try to read the xml, I want to examine the Nhibernate classes that store this after it is loaded.

My goal is to be able to, at runtime, determine the table that a given class is persisted to. I see that I can use .Net attributes on the objects themselves and therefore I could use Reflection to read those attributes. And, that is what I will have to do if I can't read it from NHibernate.

So, a pointer in the right direction would be helpful...

Thanks!
Brian


Top
 Profile  
 
 Post subject: Re: Read XML Configuration at RunTime
PostPosted: Tue Jan 31, 2006 6:38 pm 
Regular
Regular

Joined: Fri Jan 27, 2006 2:32 pm
Posts: 102
Location: California, USA
pelton wrote:
My goal is to be able to, at runtime, determine the table that a given class is persisted to.


Well, it looks as though I can do this by keeping my Configuration object that I used to create a SessionFactory. (I'm not sure why SessionFactory or Session doesn't expose a Configuration property. Maybe it does, but I can't find it).

So, once I have a Configuration object, getting the table name is pretty simple:

Code:

NHibernate.Mapping.PersistentClass c = MyConfigurationObject.GetClassMapping(typeof(MyClass));
Console.WriteLine("Table Name:  {0}", c.Table.Name);



Maybe there is an easier way to do this (like if Session or SessionFactory exposes the Configuration object used to build it)....

--Brian


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