Can you send in the generated hbm files? You'll have to specify debug="true"
in your config for them to be written to disk.

-Markus

2009/8/5 jsmorris <[email protected]>

>
> Thanks for your continued help Markus.  I now understand what you are
> saying about the HasMany side of this relationship and was able to
> make it work!  But, now the BelongsTo/Any side of the relationship is
> throwing an error.  I attempted to use this mapping on my Journal
> object to reference which object this Journal belongs to (either Foo,
> Bar, or any other IJournalable object).
>
>        [Any(IdType = typeof(Int32), MetaType = typeof(IJournalable),
> TypeColumn = "JournalableType", IdColumn = "JournalableId", Cascade =
> CascadeEnum.SaveUpdate)]
>        [Any.MetaValue("Foo", typeof(Foo))]
>        [Any.MetaValue("Bar", typeof(Bar))]
>        public IJournalable Journalable { get; set; }
>
> But, got the below errors.  I am not sure, even reading the inner
> exception, that I know where to start looking.
>
> Jason
>
> System.NullReferenceException: Object reference not set to an instance
> of an object.
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindAny(XmlNode node, Any
> model, Boolean isNullable)
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.PropertiesFromXML(XmlNode
> node, PersistentClass model, IDictionary`2 inheritedMetas, UniqueKey
> uniqueKey, Boolean mutable, Boolean nullable, Boolean naturalId)
> at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(XmlNode node,
> HbmClass classSchema, IDictionary`2 inheritedMetas)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddRootClasses(XmlNode
> parentNode, IDictionary`2 inheritedMetas)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(XmlNode node)
> at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
> NHibernate.MappingException: Could not compile the mapping document:
> (string)
> at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
> at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
> at NHibernate.Cfg.Configuration.ProcessMappingsQueue()
> at NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument
> document)
> at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String
> name)
> at NHibernate.Cfg.Configuration.AddXml(String xml, String name)
> at NHibernate.Cfg.Configuration.AddXmlString(String xml)
> at Castle.ActiveRecord.ActiveRecordStarter.AddXmlString(Configuration
> config, String xml, ActiveRecordModel model) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 761
> Castle.ActiveRecord.Framework.ActiveRecordException: Error adding
> information from class Intel.TraX.Tests.Data.Store.Journal to
> NHibernate. Check the inner exception for more information
> at Castle.ActiveRecord.ActiveRecordStarter.AddXmlString(Configuration
> config, String xml, ActiveRecordModel model) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 765
> at
> Castle.ActiveRecord.ActiveRecordStarter.AddXmlToNHibernateCfg(ISessionFactoryHolder
> holder, ActiveRecordModelCollection models) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 751
> at
> Castle.ActiveRecord.ActiveRecordStarter.RegisterTypes(ISessionFactoryHolder
> holder, IConfigurationSource source, IEnumerable`1 types, Boolean
> ignoreProblematicTypes) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 933
> at Castle.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource
> source, Type[] types) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 200
> at Castle.ActiveRecord.ActiveRecordStarter.Initialize(Assembly[]
> assemblies, IConfigurationSource source, Type[] additionalTypes) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:
> line 223
> at
> Castle.Facilities.ActiveRecordIntegration.ActiveRecordFacility.InitializeFramework(ArrayList
> assemblies) in
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\Facilities\ActiveRecordIntegration\Castle.Facilities.ActiveRecordIntegration\ActiveRecordFacility.cs:
> line 147
> at Castle.Facilities.ActiveRecordIntegration.ActiveRecordFacility.Init()
> in
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\Facilities\ActiveRecordIntegration\Castle.Facilities.ActiveRecordIntegration\ActiveRecordFacility.cs:
> line 107
> at Castle.MicroKernel.Facilities.AbstractFacility.Init(IKernel kernel,
> IConfiguration facilityConfig) in
>
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\InversionOfControl\Castle.MicroKernel\Facilities\AbstractFacility.cs:
> line 69
> at Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility
> facility) in
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\InversionOfControl\Castle.MicroKernel\DefaultKernel.cs:
> line 515
> at Castle.Windsor.WindsorContainer.AddFacility(String key, IFacility
> facility) in
> c:\TeamCity\buildAgent\work\7e4107d1782544ec\InversionOfControl\Castle.Windsor\WindsorContainer.cs:
> line 261
> at Intel.TraX.Web.IoCContainer.RegisterFacilities() in IoCContainer.cs:
> line 57
> at Intel.TraX.Web.IoCContainer..ctor(String configFileName) in
> IoCContainer.cs: line 34
> at Intel.TraX.Tests.BasePersistenceTestFixture.TestFixtureSetUp() in
> BasePersistenceTestFixture.cs: line 37
>
>
>
> On Wed, Aug 5, 2009 at 10:18 AM, Markus Zywitza<[email protected]>
> wrote:
> > Maybe I was unclear. BelongsTo won't help here, Any is the reight
> attribute.
> > You have to specify
> >
> > HasMany(typeof(Journal), ColumnKey="...", Table="...")
> >
> > This should work.
> > -Markus
> > 2009/8/4 jsmorris <[email protected]>
> >>
> >> Moved from dev list...my apologies for asking my question on the wrong
> >> list.
> >>
> >> I now understand that I need the BelongsTo, but my problem is
> >> constructing the correct BelongsTo in this situation.  All my attempts
> >> have failed.
> >>
> >> So, my Journal class needs a BelongsTo to associate it to either a Foo
> >> or Bar, so if I define this
> >>
> >>  [BelongsTo("JournalableId", Table = "Journals")]
> >>  public IJournalable Journalable { get; set; }
> >>
> >> I get the the error message.  If I type the property to either of my
> >> concrete types Foo or Bar, I do not get an error.
> >>
> >>  [BelongsTo("JournalableId", Table = "Journals")]
> >>  public Foo Journalable { get; set; }
> >>
> >> or
> >>
> >>  [BelongsTo("JournalableId", Table = "Journals")]
> >>  public Bar Journalable { get; set; }
> >>
> >> I feel that I need to be able to specify a type to the BelongsTo.  I
> >> was attempting to use the Any attribute to specify my metatype,
> >> IJournalable, as well as the concrete types, Foo and Bar,  for this
> >> association.  I believe that my Journals table would end up with
> >> columns Id, JournalableId, JournalableType where JournalableType would
> >> be either Foo or Bar.
> >>
> >> Is this type of association even possible?
> >>
> >> Thanks,
> >> Jason
> >>
> >>
> >>
> >> On Fri, Jul 31, 2009 at 7:34 PM, Markus Zywitza<
> [email protected]>
> >> wrote:
> >> > Hint: It's already explained in the exception: If you don't have a
> >> > BelongsTo
> >> > (Any doesn't count), you need to specify ColumnKey and Table.
> >> >
> >> > -Markus
> >> >
> >> > 2009/7/31 jsmorris <[email protected]>
> >> >>
> >> >> I am having trouble setting up my AR relationships.  I have tried so
> >> >> many things, but nothing seems to work.  Here is what I am trying to
> >> >> do.
> >> >>
> >> >> Foo has many Journals.  Bar has many Journals. A Journal can belong
> to
> >> >> either Foo or Bar.
> >> >>
> >> >> If I try the mapping I have below, I get the following error
> >> >>
> >> >> Castle.ActiveRecord.Framework.ActiveRecordException: ActiveRecord
> >> >> tried to infer details about the relation Bar.Journals but it could
> >> >> not find a 'BelongsTo' mapped property in the target type
> >> >> Intel.TraX.Tests.Data.Store.Journal
> >> >>
> >> >> I am probably way off on what needs to be done, but I am looking for
> >> >> any help to point me in the right direction.
> >> >>
> >> >> Thanks,
> >> >> Jason
> >> >>
> >> >>    [ActiveRecord]
> >> >>    public class Journal : DomainObject<Journal>
> >> >>    {
> >> >>        [Any(typeof(Int32), MetaType = typeof(IJournalable),
> >> >> TypeColumn = "JournalableType", IdColumn = "JournalableId", Cascade =
> >> >> CascadeEnum.SaveUpdate)]
> >> >>        [Any.MetaValue("Foo", typeof(Foo))]
> >> >>        [Any.MetaValue("Bar", typeof(Bar))]
> >> >>        public IJournalable Journalable { get; set; }
> >> >>    }
> >> >>
> >> >>    public interface IJournalable {}
> >> >>
> >> >>    [ActiveRecord]
> >> >>    public class Foo : DomainObject<Foo>, IJournalable
> >> >>    {
> >> >>        [HasMany(ColumnKey = "JournalableId")]
> >> >>        public IList<Journal> Journals { get; set; }
> >> >>    }
> >> >>
> >> >>    [ActiveRecord]
> >> >>    public class Bar : DomainObject<Bar>, IJournalable
> >> >>    {
> >> >>        [HasMany(ColumnKey = "JournalableId")]
> >> >>        public IList<Journal> Journals { get; set; }
> >> >>    }
> >> >> }
> >> >>
> >> >>
> >> >
> >> >
> >> > >
> >> >
> >> >>
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to