Hi.
It's been a while since I did an NHibernate project and I'm positive that this error i'm getting is the result of something boneheaded on my part but I just don't see it.
I'm just doing a simple test app to get back familiar with the NHibernate way of doing things and my first relationship definition is failing. I've got Users, Permissions and a join table called UserPermissions (UserPermID, UserID, PermID.)
When I run the code I get the exception listed below. Can anybody see the nature of my undoubtedly lame mistake?
I'd search for the error on here but I'm getting an error message from the search function. Checked the FAQ but to no avail.
Thanks.
NHibernate version:
1.2.0Alpha1
Mapping documents:
User:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MySqlTest.User, MySqlTest" table="users">
<id name="UserID" column="UserID" type="Int32" length="20">
<generator class="identity" />
</id>
<property name="Name" column="name" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<set name="Permissions" table="UserPermissions" inverse="false" lazy="true">
<key column="UserID"/>
<many-to-many class="MySqlTest.Permission" column="permID"/>
</set>
</class>
</hibernate-mapping>
Permission:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MySqlTest.Permission, MySqlTest" table="permissions">
<id name="PermID" type="Int32">
<generator class="identity" />
</id>
<property name="Name" column="name" type="String" length="40"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Configuration cfg = new Configuration();
cfg.AddAssembly("MySqlTest");
ISessionFactory factory = cfg.BuildSessionFactory(); //breaks here
ISession session = factory.OpenSession();
Permission addPerm = (Permission)session.Load(typeof(Permission), 1);
Permission editPerm = (Permission)session.Load(typeof(Permission), 2);
User u = (User)session.Load(typeof(User), 1);
u.Permissions.Add(addPerm);
session.Save(u);
session.Close();
Full stack trace of any exception that occurs:Code:
"NHibernate.MappingException: could not find class: MySqlTest.Permission ---> System.TypeLoadException: Could not load type 'MySqlTest.Permission', check that type and assembly names are correct\r\n at NHibernate.Util.ReflectHelper.ClassForName(String name) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Util\\ReflectHelper.cs:line 160\r\n at NHibernate.Cfg.HbmBinder.ClassForFullNameChecked(String fullName, String errorMessage) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 82\r\n --- End of inner exception stack trace ---\r\n at NHibernate.Cfg.HbmBinder.ClassForFullNameChecked(String fullName, String errorMessage) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 86\r\n at NHibernate.Cfg.HbmBinder.ClassForNameChecked(String name, Mappings mappings, String errorMessage) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 100\r\n at NHibernate.Cfg.HbmBinder.BindManyToOne(XmlNode node, ManyToOne model, String defaultColumnName, Boolean isNullable, Mappings mappings) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 826\r\n at NHibernate.Cfg.HbmBinder.BindCollectionSecondPass(XmlNode node, Collection model, IDictionary persistentClasses, Mappings mappings) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 1545\r\n at NHibernate.Cfg.HbmBinder.BindSetSecondPass(XmlNode node, Set model, IDictionary persistentClasses, Mappings mappings) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 2046\r\n at NHibernate.Cfg.SetSecondPass.SecondPass(IDictionary persistentClasses) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 1788\r\n at NHibernate.Cfg.AbstractSecondPass.DoSecondPass(IDictionary persistentClasses) in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\HbmBinder.cs:line 1713\r\n at NHibernate.Cfg.Configuration.SecondPassCompile() in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\Configuration.cs:line 885\r\n at NHibernate.Cfg.Configuration.BuildSessionFactory() in c:\\net\\nhibernate\\nhibernate\\src\\NHibernate\\Cfg\\Configuration.cs:line 997\r\n at MySqlTest.Form1.Form1_Load(Object sender, EventArgs e) in c:\\documents and settings\\skain\\my documents\\visual studio projects\\mysqltest\\form1.cs:line 120"
Name and version of the database you are using:MySql 5.0
[/code]