Ricardo: that exception looks very familiar. I committed a fix earlier today
that certainly fixed an exception very similar to that, if I were you I'd do
an update and double check it isn't already fixed.

On Tue, May 5, 2009 at 7:23 PM, Ricardo <[email protected]> wrote:

>
> I believe I am having this same issue.  I will post all my info,
> hoping to help.  I'm going to try Kevin's fix for now to see if it
> works, and if I have time, I'll also attempt to help.
>
> I have a Poll that has a list of Answers.  If I leave it at that, it
> works fine.  But as soon as I add a many-to-one of an Answer has one
> Poll, it gives me the error that's at the bottom of this.
>
> If you need anymore info, let me know.  Thanks in advance.
>
> I see the problem, and it looks to be the same as Kevin's.  Namely,
> the mapping on answer has this: <many-to-one name="Poll" column="" />
> hbm.xml:
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="">
>  <class name="OCS.Data.Entities.BaseEntity, OCS.Data,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> table="`BaseEntity`" xmlns="urn:nhibernate-mapping-2.2">
>    <id name="Id" type="Int32" column="Id">
>      <generator class="identity" />
>    </id>
>    <joined-subclass name="OCS.Data.Entities.Poll, OCS.Data,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
>       <key column="BaseEntityId" />
>      <property name="Question">
>        <column name="Question" />
>      </property>
>      <bag name="Answers">
>        <key />
>        <one-to-many class="OCS.Data.Entities.Answer, OCS.Data,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
>      </bag>
>     </joined-subclass>
>    <joined-subclass name="OCS.Data.Entities.Answer, OCS.Data,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
>       <key column="BaseEntityId" />
>      <property name="Text">
>        <column name="Text" />
>      </property>
>      <property name="Value">
>        <column name="Value" />
>      </property>
>      <many-to-one name="Poll" column="" />
>    </joined-subclass>
>  </class>
> </hibernate-mapping>
> Config:
>                                Type sessionContextType = typeof (Test);
>                                string contextClass =
> Configuration.GetConfigSetting
> ("current_session_context_class",
> sessionContextType.AssemblyQualifiedName);
>                                return Fluently.Configure()
>
>  .Database(MsSqlConfiguration.MsSql2005
>                                                .ConnectionString(c => c.
>
>  FromConnectionStringWithKey("OCSDB")))
>                                         .Mappings(m =>
>                                                  m.AutoMappings.Add(
>
>  AutoPersistenceModel.MapEntitiesFromAssemblyOf<Answer>
> ()
>
>  .Where(t => t.Namespace == "OCS.Data.Entities")
>                                                        )
>
>  .ExportTo(@"c:\logs"))
>                                        .ExposeConfiguration(c =>
>                                                                {
>
>  c.SetProperty
> ("current_session_context_class", contextClass);
>                                                                        var
> export = new SchemaExport(c);
>
>                    export.Drop(false, true);
>
>  export.Create(false, true);
>                                                                })
>                                        .BuildSessionFactory();
>
>
> Test:
>        [TestFixture]
>        public class VoteTests : BaseTestFixture
>        {
>                [Test]
>                public void GetVoteTotalsForAnswer()
>                {
>                        BeginTransaction();
>
>                        try
>                        {
>                                var poll = new Poll();
>                                var answer = new Answer("love", poll);
>                                poll.Answers.Add(answer);
>                                answer.Vote();
>
>                                FlushSession();
>
>                                var actualPoll = PollManager.Get(poll.Id);
>
>                                Expect(actualPoll.Answers.Where(a => a.Value
> == "love").First
> ().GetTotalVotes(), Is.EqualTo(1));
>                        }
>                        finally
>                        {
>                                Rollback();
>                        }
>                }
>        }
>
> BaseEntity:
>        public class BaseEntity
>        {
>                public virtual int Id { get; set; }
>        }
> Poll:
>        public class Poll : BaseEntity
>        {
>                public Poll()
>                {
>                        Answers = new List<Answer>();
>                }
>
>                public virtual IList<Answer> Answers { get; set; }
>
>                public virtual string Question { get; set; }
>        }
>
> Answer:
>        public class Answer : BaseEntity
>        {
>                public Answer(string value, Poll poll)
>                {
>                        Value = value;
>                        Poll = poll;
>                }
>
>                public Answer() {}
>
>                public virtual string Text { get; set; }
>                public virtual string Value { get; set; }
>
>                internal virtual int Votes { get; set; }
>
>                public virtual Poll Poll { get; set; }
>
>                public override string ToString()
>                {
>                        return Text;
>                }
>        }
>
>
> Error:
> VoteTests.GetVoteTotalsForAnswer : Failed
> key
> property
> bag
> key
> property
> property
> many-to-one
> id
> joined-subclass
> joined-subclass
> key
> property
> bag
> key
> property
> property
> many-to-one
> id
> joined-subclass
> joined-subclass
>
> System.IndexOutOfRangeException: Index was outside the bounds of the
> array.
> at NHibernate.Mapping.Column.set_Name(String value)
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindColumns(XmlNode node,
> SimpleValue model, Boolean isNullable, Boolean autoColumn, String
> propertyPath)
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindManyToOne(XmlNode
> node, ManyToOne model, String defaultColumnName, Boolean isNullable)
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.PropertiesFromXML(XmlNode
> node, PersistentClass model)
> at
> NHibernate.Cfg.XmlHbmBinding.JoinedSubclassBinder.HandleJoinedSubclass
> (PersistentClass model, XmlNode subnode)
> at NHibernate.Cfg.XmlHbmBinding.ClassBinder.PropertiesFromXML(XmlNode
> node, PersistentClass model)
> at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(XmlNode node,
> HbmClass classSchema)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddRootClasses
> (XmlNode parentNode)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(XmlNode node)
> at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument
> doc)
> NHibernate.MappingException: Could not compile the mapping document:
> (XmlDocument)
> 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.AddInputStream(Stream xmlInputStream,
> String name)
> at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String
> name)
> at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc)
> at FluentNHibernate.PersistenceModel.Configure(Configuration cfg) in
> PersistenceModel.cs: line 211
> at FluentNHibernate.AutoMap.AutoPersistenceModel.Configure
> (Configuration configuration) in AutoPersistenceModel.cs: line 131
> at FluentNHibernate.Cfg.AutoMappingsContainer.Apply(Configuration cfg)
> in AutoMappingsContainer.cs: line 70
> at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
> in MappingConfiguration.cs: line 53
> at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in
> FluentConfiguration.cs: line 110
> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
> incomplete configuration was used while creating a SessionFactory.
> Check PotentialReasons collection, and InnerException for more detail.
>
>
> at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in
> FluentConfiguration.cs: line 119
> at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
> FluentConfiguration.cs: line 93
> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
> incomplete configuration was used while creating a SessionFactory.
> Check PotentialReasons collection, and InnerException for more detail.
>
>
> at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in
> FluentConfiguration.cs: line 98
> at OCS.Data.NHibernate.Db.CreateSessionFactory() in Db.cs: line 68
> at OCS.Data.NHibernate.Db.get_SessionFactory() in Db.cs: line 27
> at OCS.Web.Tests.BaseTestFixture.get_Session() in BaseTestFixture.cs:
> line 19
> at OCS.Web.Tests.BaseTestFixture.BeginTransaction() in
> BaseTestFixture.cs: line 28
> at OCS.Web.Tests.ModelTests.VoteTests.GetVoteTotalsForAnswer() in
> VoteTests.cs: line 15
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to