Do I need to explicity load hibernate.cfg.xml? For some reason, it
looks like your basic test fixture calls configure *after* compiling
the mappings. Is this incorrect code in your project?

private void Configure()
{
    cfg = new Configuration();
    Assembly assembly = Assembly.Load(MappingsAssembly);

    foreach (string file in Mappings)
    {
        cfg.AddResource(MappingsAssembly + "." + file, assembly);
    }

    Configure(cfg);
    ApplyCacheSettings(cfg);
}

I looks like the above code only gives me the option to call Configure
() after the mappings are loaded. Is that right?

--
JoAnn Peeler

On Feb 20, 12:52 pm, Fabio Maulo <[email protected]> wrote:
> Probably you are not running the configuration in your test.
>
> 2009/2/20 JoAnnP38 <[email protected]>
>
>
>
>
>
>
>
> > The content of Mappings.hbm.xml looks like:
>
> > <?xml version="1.0" encoding="utf-8" ?>
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> >                                   default-cascade="save-update"
> > auto-import="true"
> >                   assembly="NHibernate.Test"
>
> > namespace="NHibernate.Test.NHSpecificTest.NH1234" >
> >        <class name="Bar" table="Bar" optimistic-lock="version">
> >                <id name="Id" column="ID" type="Int32">
> >                        <generator class="identity" />
> >                </id>
> >                <version name="Timestamp" type="binary" generated="always"
> > unsaved-
> > value="null" />
> >                <property name="AField" not-null="true" />
> >                <many-to-one name="Foo" column="FooID" cascade="all"
> > class="Foo" not-
> > null="true" />
> >        </class>
> >        <class name="Foo" table="Foo" optimistic-lock="version">
> >                <id name="Id" column="ID" type="Int32">
> >                        <generator class="identity" />
> >                </id>
> >                <version name="Timestamp" type="binary" generated="always"
> > unsaved-
> > value="null" />
> >                <property name="AField" not-null="true" />
> >                <set name="Bars" lazy="true" cascade="all"
> > access="nosetter.camelcase">
> >                        <key column="FooID" />
> >                        <one-to-many class="Bar" />
> >                </set>
> >        </class>
> > </hibernate-mapping>
>
> > Does anyone have any suggestions?
>
> > On Feb 20, 12:30 pm, JoAnnP38 <[email protected]> wrote:
> > > The full exception info is:
>
> > > NHibernate.MappingException was caught
> > >   Message="Could not compile the mapping document:
> > > NHibernate.Test.NHSpecificTest.NH1234.Mappings.hbm.xml"
> > >   Source="NHibernate"
> > >   StackTrace:
> > >        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.AddResource(String path,
> > > Assembly assembly)
> > >        at NHibernate.Test.TestCase.Configure() in D:\Projects
> > > \NHibernate.Test\TestCase.cs:line 174
> > >        at NHibernate.Test.TestCase.TestFixtureSetUp() in D:\Projects
> > > \NHibernate.Test\TestCase.cs:line 59
> > >   InnerException: System.InvalidOperationException
> > >        Message="Could not find the dialect in the configuration"
> > >        Source="NHibernate"
> > >        StackTrace:
> > >             at NHibernate.Dialect.Dialect.GetDialect(IDictionary`2
> > > props)
> > >             at NHibernate.Cfg.Configuration.AddValidatedDocument
> > > (NamedXmlDocument doc)
> > >        InnerException:
>
> > > On Feb 19, 7:48 pm, Dario Quintana <[email protected]>
> > > wrote:
>
> > > > Make sure the hbm.xml files are marked as Embedded resource.
> > > > Send it to us the inner exception, otherwise.
>
> > > > On Thu, Feb 19, 2009 at 8:23 PM, JoAnnP38 <[email protected]>
> > wrote:
>
> > > > > Based on a suggestion from Fabio Maulo I am creating a unit test that
> > > > > demonstrates a bug I might have found. First I created my own NUnit
> > > > > test until I saw on nhforge.org that I should use the
> > NHibernate.Test-
> > > > > Lite project that is posted. So I transferred my test code to here
> > and
> > > > > now I get the following error when my mappings are being compiled:
>
> > > > > NHibernate.Test.NHSpecificTest.NH1234.SampleTest (TestFixtureSetUp):
> > > > > NHibernate.MappingException : Could not compile the mapping document:
> > > > > NHibernate.Test.NHSpecificTest.NH1234.Mappings.hbm.xml
> > > > >  ----> System.InvalidOperationException : Could not find the dialect
> > > > > in the configuration
>
> > > > > What I don't understand is that the SQL dialect is specified in
> > > > > App.config ("NHibernate.Dialect.MsSql2005Dialect"), so why am I
> > > > > getting this error?
>
> > > > --
> > > > Dario Quintanahttp://darioquintana.com.ar-Hidequoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> --
> Fabio Maulo- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to