Thanks again sergey, my bad. I missed this bit, I have now set the Build Action to Embedded Resource for all the .hbm.xml files in the project.
When I run the code again with the following line commented out, again nothing is returned.
Code:
cfg.AddAssembly("TestORMNHibernate");
When I uncomment this line, this returns the following error when I try to run it:
Code:
NHibernate.MappingException: TestORMNHibernate.NHibernate.Usermodules.hbm.xml(2,2): XML validation error: Could not find schema information for the element 'urn:nhibernate-mapping-2.0:hibernate-mapping'. ---> System.Xml.Schema.XmlSchemaException: Could not find schema information for the element 'urn:nhibernate-mapping-2.0:hibernate-mapping'.
In the Comments section of
http://www.hibernate.org/362.html, there is a post by beny which states:
Quote:
urn:nhibernate-mapping-2.0 should be urn:nhibernate-mapping-2.2 for 1.2 beta
so I tried this and got the following error:
Code:
NHibernate.MappingException: TestORMNHibernate.NHibernate.Usermodules.hbm.xml(7,4): XML validation error: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:jcs-cache urn:nhibernate-mapping-2.2:cache urn:nhibernate-mapping-2.2:id urn:nhibernate-mapping-2.2:composite-id'. ---> System.Xml.Schema.XmlSchemaValidationException: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:jcs-cache urn:nhibernate-mapping-2.2:cache urn:nhibernate-mapping-2.2:id urn:nhibernate-mapping-2.2:composite-id'.
I then had a look at the .hbm.xml mapping file, it didn't contain any schema, only this message:
Quote:
<!-- composite primary key support is touchy. View the documentation for syntax. -->
So it looks like the MyGeneration template I downloaded (the one by k-dub), is going to need a bit of tweaking ;) - or else I need a new one! Any tips for a good way of creating the .hbm.xml and .cs files?
Ok, so now I've removed all the .hbm.xml and .cs mapping files except 2 of each, 1 for the Items table which I'm trying to retrieve, and another that is linked. When I run it again, I'm getting an error at line
Code:
ISessionFactory factory = cfg.BuildSessionFactory();
The error is:
Code:
NHibernate.InvalidProxyTypeException: The following types may not be used as proxies:
TestORMNHibernate.Users: method get_Userid should be virtual
TestORMNHibernate.Users: method set_Userid should be virtual
TestORMNHibernate.Users: method get_UserType should be virtual
TestORMNHibernate.Users: method set_UserType should be virtual
I think I probably need to go back to the drawing board at this stage and look at either changing the MyGeneration template to generate the .hbm.xml and .cs files, or else find a better way of creating them.