Thank you for your help.. I think I will make the distribution a "Component" that contains the dictionary, this way I can just persist the dictionary without the need of creating a custom type.
I will definitely play with it :) Thanks, David 2009/3/11 Fabio Maulo <[email protected]>: > Children should be IDictionary<Guid, decimal> (I mean the declaration in > your class). > NH don't know how instantiate and proxy your own collection. > If you want use "Distribution" class as collection you should implement a > IUserCollectionType. > > 2009/3/11 David Perfors <[email protected]> >> >> Hi Tapio, >> >> The table was deleted, that is fixed now :) >> >> After changing the mapping a littlebit, it seems to be working for the >> dictionary. I now have this mapping: >> <?xml version="1.0" encoding="utf-8" ?> >> <hibernate-mapping assembly="NHibernateDictionaryTest" >> default-cascade="save-update" >> default-lazy="false" >> namespace="NHibernateDictionaryTest" >> xmlns="urn:nhibernate-mapping-2.2"> >> <class name="NotaRow"> >> <id name="Id" type="Guid"> >> <generator class="assigned" /> >> </id> >> <property name="Description" /> >> <property name="ToPay" /> >> <map name="Children"> >> <key column="NotaRowId" /> >> <composite-index class="NotaRow"> >> <key-property name="Id" /> >> </composite-index> >> <!--<index column="NotaRowId" type="Guid" />--> >> <element column="Distribution" type="Decimal" /> >> </map> >> </class> >> </hibernate-mapping> >> >> But when I try to do it with my own Distribution class I get an >> exception (again :P) >> The class: >> public class Distribution<T> : Dictionary<T, Decimal>, IComparable<T> >> , IDictionary<T, Decimal> >> { >> // some calculation methods no custom properties >> } >> >> The exception: >> System.Transactions Critical: 0 : <TraceRecord >> xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" >> >> Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled >> >> exception</Description><AppDomain>NHibernateDictionaryTest.vshost.exe</AppDomain><Exception><ExceptionType>NHibernate.MappingException, >> NHibernate, Version=2.1.0.1001, Culture=neutral, >> PublicKeyToken=aa95f207798dfdb4</ExceptionType><Message>Error mapping >> generic collection NHibernateDictionaryTest.NotaRow.Children: expected >> 2 generic parameters, but the property type has >> 1</Message><StackTrace> at >> NHibernate.Mapping.Collection.CheckGenericArgumentsLength(Int32 >> expectedLength) >> at NHibernate.Mapping.Map.get_DefaultCollectionType() >> at NHibernate.Mapping.Collection.get_CollectionType() >> at NHibernate.Mapping.Map.get_CollectionType() >> at NHibernate.Mapping.Collection.get_Type() >> at NHibernate.Tuple.PropertyFactory.BuildStandardProperty(Property >> property, Boolean lazyAvailable) >> at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass >> persistentClass, ISessionFactoryImplementor sessionFactory) >> at >> NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass >> persistentClass, ICacheConcurrencyStrategy cache, >> ISessionFactoryImplementor factory) >> at >> NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass >> persistentClass, ICacheConcurrencyStrategy cache, >> ISessionFactoryImplementor factory, IMapping mapping) >> at >> NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass >> model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor >> factory, IMapping cfg) >> at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, >> IMapping mapping, Settings settings, EventListeners listeners) >> at NHibernate.Cfg.Configuration.BuildSessionFactory() >> at NHibernateDictionaryTest.Program.Main(String[] args) in >> >> C:\Projects\NHibernateDictionaryTest\NHibernateDictionaryTest\Program.cs:line >> 17 >> at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) >> at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence >> assemblySecurity, String[] args) >> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() >> at System.Threading.ThreadHelper.ThreadStart_Context(Object state) >> at System.Threading.ExecutionContext.Run(ExecutionContext >> executionContext, ContextCallback callback, Object state) >> at >> System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>NHibernate.MappingException: >> Error mapping generic collection >> NHibernateDictionaryTest.NotaRow.Children: expected 2 generic >> parameters, but the property type has 1 >> at NHibernate.Mapping.Collection.CheckGenericArgumentsLength(Int32 >> expectedLength) >> at NHibernate.Mapping.Map.get_DefaultCollectionType() >> at NHibernate.Mapping.Collection.get_CollectionType() >> at NHibernate.Mapping.Map.get_CollectionType() >> at NHibernate.Mapping.Collection.get_Type() >> at NHibernate.Tuple.PropertyFactory.BuildStandardProperty(Property >> property, Boolean lazyAvailable) >> at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass >> persistentClass, ISessionFactoryImplementor sessionFactory) >> at >> NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass >> persistentClass, ICacheConcurrencyStrategy cache, >> ISessionFactoryImplementor factory) >> at >> NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass >> persistentClass, ICacheConcurrencyStrategy cache, >> ISessionFactoryImplementor factory, IMapping mapping) >> at >> NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass >> model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor >> factory, IMapping cfg) >> at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, >> IMapping mapping, Settings settings, EventListeners listeners) >> at NHibernate.Cfg.Configuration.BuildSessionFactory() >> at NHibernateDictionaryTest.Program.Main(String[] args) in >> >> C:\Projects\NHibernateDictionaryTest\NHibernateDictionaryTest\Program.cs:line >> 17 >> at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) >> at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence >> assemblySecurity, String[] args) >> at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() >> at System.Threading.ThreadHelper.ThreadStart_Context(Object state) >> at System.Threading.ExecutionContext.Run(ExecutionContext >> executionContext, ContextCallback callback, Object state) >> at >> System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord> >> >> Any ideas? >> >> David >> >> > > > > -- > Fabio Maulo > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
