7

I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate.

Question: Contribute to FNH or to migrate the mappings to mapping-by-code or confORM and fixing problems/implementing features there?

Daniel Schilling
  • 4,829
  • 28
  • 60
Firo
  • 30,626
  • 4
  • 55
  • 94

3 Answers3

7

At our office, we have been using NHibernate for 3 years now. We've been thinking about making a move to Fluent Nhibernate but never made the move. Using hbm.xml files was still the easiest to debug/alter. Two common problems of those xml files are that they are all validated during the creating of the sessionfactory and they are not refactor-safe.

Due to a bug I had to update a newer release of NHibernate (we were using NHib 2.1.2GA) and when I implemented 3.2GA we also were handed the ability to use loquacious mappings (mapping by code). I decided to use Loquacious over Fluent because I don't have a dependency to another project (Fluent) and the fact that NHibernate won't be shipped if mapping by code is broken.

Be aware though, that Loquacious mapping isn't complete either. While I was mapping everything by code, I found out basic stuff like property-ref wasn't always implemented. Thus even though it's shipped, it's not 100% complete. And while this will not come as a shocker, it has bugs. yes. really. ;-)

for more info on (reported) bugs, check out the NHibernate bug database: https://nhibernate.jira.com/browse/NH

Hope this helps. Regards, Ted

TedOnTheNet
  • 1,082
  • 1
  • 8
  • 23
  • this helps a but. So i will delay the move as long as i can, but there are still pending issues for me hanging around and we are going to produce prototypes of a legacy db mapped with FNH soon, so I'll either have to fix the issues, work around them or migrate (and fix). – Firo Nov 23 '11 at 16:02
  • perhaps you can tell me what the stuff is you're missing in Fnh? maybe I can tell you if its missing in Loquacious too... – TedOnTheNet Nov 23 '11 at 16:08
  • FNH 1.2 is missing equivalen of , FNH 1.3 alpha has bug with more than one Keycolum in joinedsubclass. And can i map nonexistant defaultproperties like in http://elegantcode.com/2009/07/13/using-nhibernate-for-legacy-databases/? – Firo Nov 23 '11 at 16:22
  • inserting fields into the database without having properties in your domain isn't possible unless you use a DTO or something likewise. If you check my profile, you will see I have a simular question which is still unanswered. I already know the answer though. – TedOnTheNet Nov 25 '11 at 14:21
  • .. and your list column problem can be mapped using NH 3.2 mapping by code for instance: List(x => x.YourCollectionPropertyHere, map => { map.Key(k => k.Column("KeyColumnInDetailTableHere")); map.Index(i => { i.Column("IndexColumnNameHere"); i.Base(1); }); }, r => r.OneToMany(x => x.Class(typeof(DetailClassHere)))); – TedOnTheNet Nov 25 '11 at 14:23
  • how do i specify the equivalent of `` in mapping by code? cant figure it out – Firo Nov 25 '11 at 16:13
5

thx to @TedOnTheNet i will continue to use and contribute to FNH, because it will take a while until mapping-by-code reaches FNH in some areas

  • Automapping
  • Fluent API tells a lot better which possibilities there are
  • far more verbose mappings
  • .Database(SQLiteConfiguration.Standard.InMemory()) is still easier to figure out than

    .DataBaseIntegration(db =>
    {
        db.ConnectionString = ???;
        db.Dialect<SQLiteDialect>();
        db.Driver<???>();
    });
    

and some features:

  • CompositeId and Table per Subclass
  • default values for legacy columns
  • property refs

Update: some features from hbm.xml (and FluentMapping) will not be possible at all with mapping by code:

Community
  • 1
  • 1
Firo
  • 30,626
  • 4
  • 55
  • 94
2

NH 3.2 does not have anything remotely equivalent to FNH's Automapping, as far as I can tell. (For me, that would be a dealbreaker).

Edit

The FNH Automapper can deal with most of the common patterns in an object model, such as inheritance, one-to-many relationships, self-referencing, etc - without requiring any help from the programmer. So far, pure NH has not achieved this level of automation.

Also, James Gregory has publicly stated that he will continue to develop FNH, at least in the near term. (Think I saw this on the FNH Google group a few months back, but I'm not sure exactly where).

Tom Bushell
  • 5,865
  • 4
  • 45
  • 60
  • 2
    not completely true see http://fabiomaulo.blogspot.com/2011/04/nhibernate-32-mapping-by-code_13.html – Firo Nov 24 '11 at 08:55
  • @Firo - I looked at your link - it describes "Mapping By Convention", and Fabio basically says in the first couple of paragraphs that "some people call this automapping, but I don't". FNH also does mapping by convention, but FNH's automapping provides another level on top of that. The programmer just has to tell the Automapper which assemblies contain the POCO classes to map, and it does the rest. It's much more convenient, but just as powerful, because you can also add your own conventions or overrides for special cases. So, I stand by my answer, but think I'll add some more detail. – Tom Bushell Nov 28 '11 at 15:57
  • i wanted to express that with "not completly", but you are right FNH Automapping is far easier. I used it in a production app and am really happy with the results. – Firo Nov 28 '11 at 18:03