Click here to Skip to main content
12,625,447 members (36,564 online)
Rate this:
 
Please Sign up or sign in to vote.
I am trying to implement NHibernate 3.2.2 updating application coded originally written with NHibernate 1.2.1. Needless to say, I have needed to make a number of changes just to successful ly compile the code. I am now stuck with the following exception that occurs when I attempt to read any list from the database:
Exception occurred getter of Business.PersistableEntityBase.ObjectID
The inner exception is:  Object does not match target type.
The really odd thing is that the class in question, the PersistableEntityBase, was never been mapped for nHibernate in an xxxx.hbm.xml file because it is an abstract class used as the base class for all of the objects we are persisting with NHibernate.

Here is the class:
[Serializable]
public abstract class PersistableEntityBase
{
    public Guid ObjectID { get; set; }
    public int Version { get; set; }
}
From my research, it seemed that the newer version of NHibernate required that I create a mapping for this class so I added the following:

<?xml version="1.0" encoding="utf-8" ?>
 
<hibernate-mapping
	xmlns="urn:nhibernate-mapping-2.2"
	assembly="Business"
	namespace="Business">
 
	<class name="PersistableEntityBase" abstract="true" >
 
		<id
			name="ObjectID"
			column="objectID"
			type="Guid">
 
			<generator class="guid.comb" />
		</id>
 
		<version
			name="Version"
			column="version"
			type="Int32" />
 
	</class>
</hibernate-mapping>

After adding the above mapping file, I got the following exception as soon as I attempt to run the app:

"The following types may not be used as proxies:
\Business.PersistableEntityBase: method get_ObjectID should be 'public/protected virtual' or 'protected internal virtual'
\Business.PersistableEntityBase: method set_ObjectID should be 'public/protected virtual' or 'protected internal virtual'
\Business.PersistableEntityBase: method get_Version should be 'public/protected virtual' or 'protected internal virtual'
\Business.PersistableEntityBase: method set_Version should be 'public/protected virtual' or 'protected internal virtual'
After adding the modifers indicated by the exception, the application would successfully start up, but now when I run the list page, I again receive the original exception:
Exception occurred getter of Business.PersistableEntityBase.ObjectID
The inner exception is:  Object does not match target type.

Any help would be greatly appreciated
Posted 8-Nov-12 5:26am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100