views:

220

answers:

5

I want to auto generate .hbm mapping files from my domain objects

A: 

Well, short question, shorter answer: yes.

Great flexibility for mapping your entities to tables using attributes to decorate your properties.

And multiple DB support plus good query functionality.

And yes, FluentHibernate generates the XML mapping files for you.

Wim Hollebrandse
A: 

You might want to look at this SO question, assuming you are talking about tools to generate mapping files.

Jason Whitehorn
A: 

CodeSmith. It allows you to generate the entity class and the hbm.xml mapping files. All you have to do, is to specify the database instance and Codesmith will reverse engineer from there.

The only problem is that it's not free.

Ngu Soon Hui
The question is about generating the mapping files from the domain objects, not from the database.
Michael Maddox
+5  A: 

Fluent NHibernate will allow you to generate the mapping using actual code. It includes automapping features that follow a convention based approach. You can then use your code mapping to generate the xml mapping files.

Joseph
how is?i couldnt find.
tobias
A: 

I've used the World's Simplest Code Generator for this. I paste the class properties into the top window, the following pattern into the second window, and set the "Columns separated by" to a space.

<property name="$3" />

I've saved this as a macro (click **** ADD your own ** in the drop down) so I can do it repeatedly. Obviously this doesn't cover primary key generation, many-to-one etc. but it is a good start to get most of it done quickly

harriyott