views:

83

answers:

3

I'm going to refactor a growing project from using Castle Activerecord to pure NHibernate or Fluent NHibernate with Service/Repository pattern and POCO.

What would be an easiest way to obtain hbm xml from existing Castle Activerecord model?

Another question, is it possible to convert hbm to Fluent NH and vice versa?

+1  A: 

http://stw.castleproject.org/Active%20Record.Configuration%20Reference.ashx

You can also output nhibernate mapping files to the AppDomain.BaseDirectory.

<activerecord isDebug="true"><config></config></activerecord>

I think that should give you the mapping file in your application directory

remi bourgarel
Thanks a lot, that worked for me. Hope i'm not going to need to do it again because writing to bin folder at runtime is not totally a clean way.
George Polevoy
+3  A: 

Remi already pointed out how to generate hbm from ActiveRecord. It's also possible to generate hbm mappings from Fluent NHibernate by using ExportTo(). It's not possible to convert hbm to FNH (that is, C#) code, but you can load them from FNH.

Using Castle ActiveRecord does not imply that you can't use repositories. In fact, Castle ActiveRecord does not force you to use the ActiveRecord pattern, and it doesn't even require you do inherit ActiveRecordBase in your persistent classes. You can use ActiveRecordMediator as a repository, or wrap it in a repository interface/implementation as Rhino.Commons does.

Mauricio Scheffer
I'm already using ActiveRecordMediator, but still have to have the attributes, that is what i want to get rid of. I'm up to make entities totally persistence-ignorant.
George Polevoy
A: 

There is at least one open source project to convert HMB to FNH:

http://code.google.com/p/nhibernate-hbm-to-fluent-converter/

As others have already said, you can easily convert ActiveRecord to HBM and FluentNHibernate to HBM.

Michael Maddox