Category: Open Source

NHibernate MappingException association references unmapped class

NHibernate Benjamin Perkins

During the mapping process you may encounter this error. In my situation the case was that I had the wrong namespace identified within the class attribute within a bag element containing a one-to-many element, like the below. <bag name=”Customer”>    <key column=”CUST_ID” />    <one-to-many class=”CompanyName.SysName.Nhibernate.Common.Customer” /> </bag> Instead of Common I had another directory […]

Read More →

Nhibernate QuerySyntaxException is not mapped from

NHibernate Benjamin Perkins

An important step which is often overlooked when beginning the process of mapping your database is to set the Build Action to Embedded Resource. (Buildvorgang – Eingebettete Resource). If you forget to do this you may receive a QuerySynataxException stating that the … is not mapped [from …]. It is also possible to store the […]

Read More →

NHibernate could not execute query, ORA-00904 invalid identifier

NHibernate Benjamin Perkins

This is a pretty easy one to solve. This happens because the column attribute in the mapping file does not exist on the database being accessed. <property  name=”SpelledWrong”               column=”SPELLDWRONG”               type=”string” />     More than likely there is a spelling mistake or the column doesn’t exist on the table being mapped.

Read More →

NHibernate Serialized startup

NHibernate Benjamin Perkins

In all of my NHibernate implementations I serialize the startup. It saves a noticeable amount of time. We know that without it, NHibernate validates all the mapping files each time we start the program. If we only have 1 or 2 simple files it is not a problem, however, if you have a large implementation, […]

Read More →

Using LIKE with LINQ to NHibernate in C#

NHibernate Benjamin Perkins

The equivalent to LIKE via the LINQ to NHibernate provider is Contains. An example of a LINQ to NHibernate that will return a result set matching a search like parameter is below. IQueryable<Classname> linqLIKE =         (from m in session.Query<Classname>()          where m.Code.Contains(“%dex%”)          orderby m.CreateDate          select m); IList<Classname> ListLIKE = linqLIKE.ToList(); The above […]

Read More →