I have been a programmer for two years already and I have decided to start a journal of the things I experience in my work that can help others like me.
I am currently in a project with more than 1 team doing an application and yesterday after the merge we were experiencing this exception. Upon further investigation we saw that we have an objects which have the same name but in 2 different namespace.Mapping 1:<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateDemo.VO.Customer, NHibernateDemo" table="VOCustomer">
<id name="Id" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" not-null="true"/>
<property name="LastName" column="LastName" not-null="true" />
<property name="Email" column="Email" not-null="true" />
</class>
</hibernate-mapping>
Mapping 2:
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernateDemo.AC.Customer, NHibernateDemo" table="ACCustomer">
<id name="Id" column="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" not-null="true"/>
<property name="LastName" column="LastName" not-null="true" />
<property name="Email" column="Email" not-null="true" />
</class>
</hibernate-mapping>
The solution was to add "auto-import= false" in the mapping file and use the fully qualified name in the two mapping files.
<hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2" auto-import="false">
But what does the auto-import attribute do? From the NHibernate Reference Documentation it says that it lets us use unqualified class names in the query language, by default. And it is set as true by default.