Andy White
Andy White

Reputation: 88355

NHibernate Fluent vs. Attributes

I'm interested in moving some NHibernate configurations/mappings into the code to help with some maintenance issues. Can anyone provide any advice/pros/cons/comparisons of Fluent NHibernate vs. NHibernate.Mapping.Attributes?

I have some experience with Java Hibernate annotations, which I liked, but I'm curious if the NHibernate attributes are comparable, and whether Fluent provides any major upsides/downsides that should be considered.

Upvotes: 14

Views: 4880

Answers (2)

Moshe Hoadley
Moshe Hoadley

Reputation: 11

NHibernate now supports JPA (called NPersistence or NPA for the .NET platform) including JPA annotations. It is the best way to map your entities and have your code portable for other vendors as well. check it out:

www.npersistence.com

Upvotes: 0

James Gregory
James Gregory

Reputation: 14223

I don't think anybody has done any outright comparisons. It falls down to how comfortable you are with decorating your entities with attributes. Fluent NHibernate is aimed at letting you use NHibernate with a completely unpolluted model, while attributes require you to alter your entities; this is a persistence concern leaking into your domain. Whether that's a problem for you is whether you should choose attributes or not.

Fluent NHibernate also throws a few more things to the table than just mappings. There's also the auto mappings which allow you to automatically map your domain. There's the conventions support which allow you to greatly reduce repetition in your design. I won't repeat everything, but you can read more on the Fluent NHibernate wiki.

Upvotes: 19

Related Questions