I'm trying to use an idbag to contain a many-to-any list of objects.  
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Framework.Core.Entities" assembly="Framework.Core" default-access="field.camelcase">
   
   <class name="Document" table="Documents" lazy="true">
      
      <id name="Id" column="DocumentID" unsaved-value="0" >
         <generator class="native" />
      </id>
      
      <version name="Version" column="Version"  />
      
      <property name="Description" column="Description" length="255" />
              
          <idbag name="Associations" table="DocumentAssociations" lazy="true" cascade="all">
          
             <collection-id column="AssociationID" type="Int32">
                <generator class="native"/>
             </collection-id>
          
         <key column="AssociatedDocumentID" />
         
         <many-to-any id-type="Int32" meta-type="string">
         
            <meta-value value="Framework.Core.Entities.Customer" class="Customer"/>
            <meta-value value="Framework.Core.Entities.User" class="User"/>
            <meta-value value="Framework.Core.Entities.Contractor" class="Contractor"/>
            
            <column name="entityType"/>
            <column name="entityId"/>
            
         </many-to-any>
      </idbag>
    
    
   </class>
</hibernate-mapping>
Whenever I try to add an item to the collection I get the following exception:
Code:
[2192] NHibernate.Util.ADOExceptionReporter: 2005-11-21 18:00:17,760 
[624] DEBUG [(null)] <(null)> - could not insert collection: [Framework.Core.Entities.Document.Associations#182527] 
[2192] System.InvalidCastException: Object must implement IConvertible. 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() 
[2192]    at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) 
[2192]    at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount) 
[2192]    at NHibernate.Collection.AbstractCollectionPersister.Recreate(PersistentCollection collection, Object id, ISessionImplementor session) 
[2192] NHibernate.Util.ADOExceptionReporter: 2005-11-21 18:00:17,760 [624] WARN  [(null)] <(null)> - System.InvalidCastException: Object must implement IConvertible. 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() 
[2192]    at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) 
[2192]    at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount) 
[2192]    at NHibernate.Collection.AbstractCollectionPersister.Recreate(PersistentCollection collection, Object id, ISessionImplementor session) 
[2192] NHibernate.Util.ADOExceptionReporter: 2005-11-21 18:00:17,760 [624] ERROR [(null)] <(null)> - Object must implement IConvertible. 
[2192] NHibernate.ADOException: 2005-11-21 18:00:17,760 [624] ERROR [(null)] <(null)> - could not insert collection: [Framework.Core.Entities.Document.Associations#182527] 
[2192] System.InvalidCastException: Object must implement IConvertible. 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() 
[2192]    at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) 
[2192]    at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount) 
[2192]    at NHibernate.Collection.AbstractCollectionPersister.Recreate(PersistentCollection collection, Object id, ISessionImplementor session) 
[2192] NHibernate.Impl.SessionImpl: 2005-11-21 18:00:17,760 [624] ERROR [(null)] <(null)> - could not synchronize database state with session 
[2192] NHibernate.ADOException: could not insert collection: [Framework.Core.Entities.Document.Associations#182527] ---> System.InvalidCastException: Object must implement IConvertible. 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) 
[2192]    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() 
[2192]    at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) 
[2192]    at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount) 
[2192]    at NHibernate.Collection.AbstractCollectionPersister.Recreate(PersistentCollection collection, Object id, ISessionImplementor session) 
[2192]    --- End of inner exception stack trace --- 
[2192]    at NHibernate.Collection.AbstractCollectionPersister.Recreate(PersistentCollection collection, Object id, ISessionImplementor session) 
[2192]    at NHibernate.Impl.ScheduledCollectionRecreate.Execute() 
[2192]    at NHibernate.Impl.SessionImpl.Execute(IExecutable executable) 
[2192]    at NHibernate.Impl.SessionImpl.ExecuteAll(IList list) 
[2192]    at NHibernate.Impl.SessionImpl.Execute() 
[2192] NHibernate.Transaction.AdoTransaction: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - rollback 
[2192] NHibernate.Transaction.AdoTransaction: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - running AdoTransaction.Dispose() 
[2192] NHibernate.Impl.SessionImpl: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - transaction completion 
And here's the debug output specifying the SQL statement and the values bound to the parameters:
Code:
[2192] NHibernate.Impl.BatcherImpl: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - Building an IDbCommand object for the SqlString: INSERT INTO DocumentAssociations (AssociatedDocumentID, AssociationID, entityType, entityId) VALUES (:AssociatedDocumentID, :AssociationID, :entityType, :entityId) 
[2192] NHibernate.Type.Int32Type: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - binding '182527' to parameter: 0 
[2192] NHibernate.Type.StringType: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - binding 'Framework.Core.Entities.Customer' to parameter: 2 
[2192] NHibernate.Type.Int32Type: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - binding '1' to parameter: 3 
[2192] NHibernate.Type.Int32Type: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - binding 'System.Object' to parameter: 1 
[2192] NHibernate.Impl.BatcherImpl: 2005-11-21 18:00:17,760 [624] DEBUG [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0 
I'm completely stumped - is anyone else using idbags with an identity column successfully?  Is this a bug?
Cheers,
Symon.