-->
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: From class to .hbm.xml file
PostPosted: Tue Nov 13, 2007 12:44 pm 
Regular
Regular

Joined: Fri May 05, 2006 11:54 am
Posts: 51
Hi all,

Is there any tool anybody knows of that can generate an .hbm.xml from a .cs class file.

I realise I should be using ActiveRecord but it is a bit late in the day for that.

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 13, 2007 3:37 pm 
Regular
Regular

Joined: Wed Aug 15, 2007 7:37 am
Posts: 73
Have you had a look at the NHibernate.Mapping namespace? It allows you to put attributes into the class file rather than explicitly writing an hbm.xml file. Check the documentation appendices for details. Otherwise not sure what you mean.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 5:32 am 
Regular
Regular

Joined: Fri May 05, 2006 11:54 am
Posts: 51
I will definitely check that out.

I guess what I wanted was to be able to point some tool at a .cs file and generate the .hbm.xml.

I am using the schemaexport facility to generate the db but am getting dragged down writing the mapping file.

What advantage does active record have over the mapping attributes?

If any


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 14, 2007 6:53 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I would say that essentially the mappings are the part that you have to do explicitly because they are the mechanism for defining how your classes relate to your underlying database. How can any tool know automatically what database table or field a specific property of a class is supposed to map to? This is something you need to provide as the architect of the solution.

Once you have mapping files you *could* potentially generate classes or the database from these because information about both exists in the mapping. I wouldn't recommend generating classes from mappings, but it can work quite well for generating the database.

Cheers,

Symon.


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.