March 9, 2008 at 12:42 pm (dotnet)
Tags: nhibernate
I encountered two errors in my code related to mapping.
First, there was incompatiblitity between IList (which was how I defined my collection properties in the Resume object, like Education History) and NHibernate’s Set mapping. (It turns out that Set derives from a non-native library called Iesi.Collections. I tried referencing Iesi.Collections in my code but it seems that it couldn’t find it in my NHibernate.dll.) It was resolved by changing the <set> tag in my map to a <bag> tag.
The second was some loading problem when my code tried to call the collection values. I learned that the bi-directional association which I set into my mapping doesn’t work for indexed collections like IList. I then took out the many-to-one tag, and it worked.
With these major mapping issues ironed out, I can now proceed with completing the DAO (data access object) implementation of my resume schema, and then move on to creating the UI forms for them.
Comments
March 5, 2008 at 1:10 am (dotnet)
Tags: nhibernate
I decided to forego the SCSF implementation of the Resume Builder after repeatedly getting assembly errors related to my references to Microsoft.Practices.CompositeUI library.
The advice was to delete the compiled dll files from the Debug / Bin folder. I did this a number of times and still get errors occassionally.
I deemed my SCSF installation unstable and went ahead to doing a plain old Windows form. I am currently in the process of incorporating NHibernate.
Initial challenges to installing NHibernate to my project involved getting errors related to configuration, in particular, Null Reference Exception. NHibernate has its own sequence of looking for the configuration file, and realized that I didn’t have to refer to the default configuration file explicitly. I merely had to ask the configuration object to add my current assembly, via AddAssembly, and moved my configuration settings from an external hibernate.cfg.xml file into app.config*. It worked.
*NHibernate has a number of ways to read configuration. You can set it programmatically by invoking methods directly, but this will reduce the maintainability of your app since you’ll need to recompile everytime settings need to be changed. You can add configuration entries into your app.config or web.config, or you can put the config in an external file, like hibernate.cfg.xml.
Having resolved that, I am now working on the mapping file. I have yet to fully familiarize myself with how it deals with one-to-many relationship collections, and other mapping concerns.
2 Comments