R – Complicated NHibernate component mapping

componentsinheritancemappingnhibernate

EDIT: I simplified the problem to leave only what really bothers me.

Hello all,

I am trying to make the following mapping.

In my database, I have a table called "ReportRowValue" containg the following columns:

  • RowNumber
  • ColumnNumber
  • StringValue
  • LongValue
  • DateValue
  • Value

In my code I want to get a more usable structure by creating several two classes from this one table. I guess this should be done using components and inheritance but I did not managed to create a working mapping file. What I want in code should look like this:

ReportRow

  • RowNumber
  • Values (collection of ReportValue below)

ReportValue (being an abstract class)

  • ColumnNumber
  • Value

ReportValueString / ReportValueLong / ReportValueDate (each one inheriting from ReportValue)


  • Value (each one having a Value property of its one type)

And that's about all!

Does anyone can point me how to create an nhibernate mapping file/files for doing that?

Thanks,

Meigetsu

Best Answer

There is couple of tools that maps and builds class for you one of them is

mygeneration is the software http://sourceforge.net/projects/mygeneration/

In this page you find the templates that you need to run with the softwarehttp://www.mygenerationsoftware.com/TemplateLibrary/Archives/?query=nhibernate

After you have this in the mygeneration tool you only connect to your DB and it will generated for you

Related Topic