Hibernate version:1.0.2.0
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="TMSEntities" namespace="TMS.CAP.Entities">
<class name="CallCentre" table="CallCentre">
<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<version column="hibernateversion" type="Int32" name="Hibernateversion" />
<bag name="RaisedByCallCentreIDApplicationList" inverse="true" lazy="true" >
<key column="RaisedByCallCentreID" />
<one-to-many class="Application" />
</bag>
<bag name="CallCentreIDSupportTicketList" inverse="true" lazy="true" >
<key column="CallCentreID" />
<one-to-many class="SupportTicket" />
</bag>
<property column="Description" type="String" name="Description" not-null="true" length="64" />
<property column="CreatedDate" type="DateTime" name="CreatedDate" />
<property column="CreatedBy" type="Guid" name="CreatedBy" />
<property column="UpdatedDate" type="DateTime" name="UpdatedDate" />
<property column="UpdatedBy" type="Guid" name="UpdatedBy" />
<property column="Active" type="Boolean" name="Active" not-null="true" />
</class>
</hibernate-mapping>
Hi, I am trying to retrieve a list of CallCentre classes (as described in the mapping file above) from my SQL server 2005 db. Normally this works fine, if for example I do the following:
Code:
CallCentreDataAccess a = new CallCentreDataAccess();
List<CallCentre> b = a.LoadCallCentreList();
However I am trying to create an instance of CallCentreDataAccess using reflection, and to invoke the LoadCallCentreList() method dynamically. The method is invoked ok, but throws an exception from within the NHibernate code. the exception is as follows:
Exception: {"Exception has been thrown by the target of an invocation."}
Inner Exception: {"in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [ from CallCentre order by Description]"}
The code to execute the method by reflection is as follows:
Code:
// get the type
Type theType = dataAccess.GetType("TMS.CAP.DataAccess.CallCentreDataAccess");
// create an instance
ConstructorInfo con = theType.GetConstructor(Type.EmptyTypes);
object instance = con.Invoke(new object[] { });
// Now call the method
MethodInfo loadListMethod = theType.GetMethod("LoadCallCentreList");
object o = new object();
o = loadListMethod.Invoke(instance, null);
I have stepped through the hibernate source to the line responsible, and compared it against a call to this method that works. It appears that the name of the entity I am retrieving loses the full assembly and namespace names in the reflected version, i.e.
Non reflected version: Assembly.Namespace.CallCentre
Using refleciton: CallCentre
This is the only difference I could see... If anyone could provide me with any suggestions as how to correct this issue I would be very grateful!
Cheers.[/code]