S#arp Architecture NHibernate instead of Fluent NHibernate - fluent-nhibernate

Is it possible to use NHibernate XML mapping files instead of Fluent NHibernate in S#arp Architecture framework?

Yes you can. Take a look at the Northwind sample app's NHibernate.config (the commented mapping element and the related comments)

Related

NHibernate: combine fluent configuraiton with attribute-based configuration

In Entity Framework it is possible to combine fluent configuration with attribute-based configuration.
As in NHibernate both configuration approaches are different projects I guess they're not combineable, however, maybe I'm misunderstood.
Is it possible to combine both approaches in NHibernate or not?
No, you have to choose what type of configuration (or mapping) you want to do. Fluent NHibernate, Xml, Attributies. You do not need to create your configuration in a separated project, but it is a good pratice to keep the single responsability for each part of your code. I really recommend you mapping using the fluent NHibernate.
This article show each type of mapping:
http://www.davesquared.net/2008/09/nhibernate-mappings-using-xml.html

nhibernate mapping generator integrated to build

I have searched for automatic mapping generator for nhibernate. So far I have tried following
NHibernate Mapping Generator
Devart Entity Developer
Codesmith generator
From those Nhibernate Mapping Generator is the only one that supports NH style fluent mapping by default. Devart and codesmith provides possibility to write own templates that would do the job. Devart and Codesmith also has "challenges", when you want mappings and entities be located in different assemblies.
I would like to ask, if you guys have any experience from the tools above? Also if you have any other tools you could suggest to me.
I am also interested in integrating those tools into CI environment. Whenever DB changes, I want entities and mapping be generated automatically.
I use Devart Entity Developer and it does support fluent nHibernate mapping. In-fact I use this on all of my projects. You simply add the fluent template from those provided and configure the output location. It generates the mapping code files automatically based of the model you load in from your database every time you build the project. It integrates well into Visual Studio if required. I would thoroughly recommend you give the 30 day trial ago.
Devart Entity Developer
In particular I draw your attention to this paragraph:
Entity Developer NHibernate mapping generator can generate both XML and fluent mapping. For XML mapping you may customize output settings, use the File per class option. XML mapping is generated as an embedded resource by default. Our NHibernate designer provides full support for Fluent NHibernate mapping - it supports all kinds of inheritances, components, composite IDs, etc.

Can Fluent NHibernate support all mappings from NHibernate

I want to use Fluent NHibernate with NHibernate. But I want to find out whether Fluent NHibernate support all mappings from NHbernate. Or is it better to stick with NHibernate?
Fluent NHibernate supports automappings, standard nhibernate xml mappings (hbm) and of course Fluent style mappings. You can mix and match any of those mappings with Fluent NHibernate.
Fluent does not support the new mapping by code style introduced in version 3.2 (they're really different animals) of NHibernate but I'm not sure that this is really an issue. Personally I would recommend using Fluent at this point because there is far more documentation and the user base is larger than mapping by code.
Fluent NHibernate is fairly easy to use and definitely has it's advantages over xml style (hbm) mappings. You can read about this more on the Fluent Wiki
just FYI; I tried using standard hbm.xml for mapping "many-to-any" which is currently not supported by fluent nhibernate;
tried both Configuration.AddXmlFile and HbmMappings
both still failed with error message saying invalid properties "many to any"

From C# to hbm.xml

I'm looking for a NHibernate Mapping generator which could generate a mapping file (hbm) and SQL Script from a C# class. I've found generators for the other way around, but not for this case.
Can you guys point me to nice generator?
Thanks a lot!
With Fluent NHiberate you can do without mapping files. In the instances where the automapping doesn't work, you can override.
This post discusses schema generation
Fluent Nhibernate Schema Generation
The newest, fastest and most extensible way to configure NHibernate is ConfORM.
You don't need to generate xml files (although you can do so if you want). It's an order of magnitude faster than Fluent NHibernate and, overall, less work.
For some examples, read Fabio Maulo's posts.

How to get XML representation of a fluent mapping - is it possible?

As the title says, is it possible to get hands on the XML representation of a fluent nhibernate mapping? And if it is, can this be used directly with Hibernate for Java?
There's a section in the Fluent NHibernate wiki covering the export of the xml mapping. Section at the bottom headed 'Exporting hbm.xml mappings'
Have not tried it but don't see any reason why the mapping file shouldn't work in Hibernate with minimal modification