-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NHibernate.MappingException: Could not compile the mapping
PostPosted: Fri May 09, 2008 6:04 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
Hello,

I am new to NHibernate. I made al little example but alway get an NHibernate.MappingException (see at the end). I could not solve my problem with forum and google.

Here are the facts:

Hibernate version: 2.0.0.1001

Mapping documents:

Storage.hbm.xml -> marked as embeded Resource in VS 2005

Code:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="DBHibernate.Storage, DBHibernate" table="STORAGE">
    <id name="Id" column="STORAGE_ID" type="int">
      <generator class="assigned" />
    </id>
    <property name="Tower" column="TOWER" type="Int" length="40"/>
    <property name="Side" type="String" length="40"/>
    <property name="Area" type="Int"/>
    <property name="Tray" type="String" length="40"/>
    <property name="Size" type="Int"/>
  </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Code:

            Configuration cfg = new Configuration();
            cfg.AddAssembly("DBHibernate");

            ISessionFactory factory = cfg.BuildSessionFactory();
            ISession session = factory.OpenSession();

            Storage test = (Storage)session.Load(typeof(Storage), 2);
           
           
            ITransaction transaction = session.BeginTransaction();

           
            IList storList = session.CreateCriteria(typeof(Storage)).List();
            foreach (Storage stor in storList)
            {
                System.Diagnostics.Debug.WriteLine(stor.Tower + stor.Area + stor.Side);
            }
...



Name and version of the database you are using:

Oracle 10g
asdbtest

Debug level Hibernate log excerpt:
ALL

.net Class Storage.cs:

Code:

using System;
using System.Collections.Generic;
using System.Text;

namespace DBHibernate
{
    public class Storage
    {
        private int id;
        private int tower;
        private string side;
        private int area;
        private string tray;
        private int size;

        public Storage()
        {
        }

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public int Tower
        {
            get { return tower; }
            set { tower = value; }
        }

        public string Side
        {
            get { return side; }
            set { side = value; }
        }

        public int Area
        {
            get { return area; }
            set { area = value; }
        }

        public string Tray
        {
            get { return tray; }
            set { tray = value; }
        }

        public int Size
        {
            get { return size; }
            set { size = value; }
        }

    }
}


Full stack trace of any exception that occurs:

Quote:
78 [10] INFO NHibernate.Cfg.Environment (null) - NHibernate 2.0.0.1001 (2.0.0.10
01)
109 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration sectio
n not found in application configuration file
109 [10] INFO NHibernate.Cfg.Environment (null) - Bytecode provider name : lcg
109 [10] INFO NHibernate.Cfg.Environment (null) - Using reflection optimizer
125 [10] INFO NHibernate.Cfg.Configuration (null) - Searching for mapped documen
ts in assembly: DBHibernate
125 [10] INFO NHibernate.Cfg.Configuration (null) - Mapping resource: DBHibernat
e.Storage.hbm.xml
156 [10] ERROR NHibernate.Cfg.Configuration (null) - Could not compile the mappi
ng document: DBHibernate.Storage.hbm.xml
NHibernate.MappingException: Could not compile the mapping document: DBHibernate
.Storage.hbm.xml ---> System.Collections.Generic.KeyNotFoundException: Der angeg
ebene Schlüssel war nicht im Wörterbuch angegeben.
bei System.ThrowHelper.ThrowKeyNotFoundException()
bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
bei NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) in c:\DATA\Pro
jects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Dialect\Dialect.cs:Zeile
173.
bei NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) i
n c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\Configur
ation.cs:Zeile 428.
--- Ende der internen Ausnahmestapelüberwachung ---


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 09, 2008 6:08 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
Hi,
take the type "Int32" for your integer columns.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 09, 2008 7:03 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
typhos wrote:
Hi,
take the type "Int32" for your integer columns.


Thanks for your quick help, but it doesn't work.

I get the same Exception.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 09, 2008 7:18 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Sounds like hibernate has a problem finding the dialect. Can you post your configuration ? What dialect do you use ?

Quote:
156 [10] ERROR NHibernate.Cfg.Configuration (null) - Could not compile the mappi
ng document: DBHibernate.Storage.hbm.xml
NHibernate.MappingException: Could not compile the mapping document: DBHibernate
.Storage.hbm.xml ---> System.Collections.Generic.KeyNotFoundException: Der angeg
ebene Schlüssel war nicht im Wörterbuch angegeben.
bei System.ThrowHelper.ThrowKeyNotFoundException()
bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
bei NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) in c:\DATA\Pro
jects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Dialect\Dialect.cs:Zeile
173.
bei NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) i
n c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\Configur
ation.cs:Zeile 428.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 1:17 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
wolli wrote:
Sounds like hibernate has a problem finding the dialect. Can you post your configuration ? What dialect do you use ?

Quote:
156 [10] ERROR NHibernate.Cfg.Configuration (null) - Could not compile the mappi
ng document: DBHibernate.Storage.hbm.xml
NHibernate.MappingException: Could not compile the mapping document: DBHibernate
.Storage.hbm.xml ---> System.Collections.Generic.KeyNotFoundException: Der angeg
ebene Schlüssel war nicht im Wörterbuch angegeben.
bei System.ThrowHelper.ThrowKeyNotFoundException()
bei System.Collections.Generic.Dictionary`2.get_Item(TKey key)
bei NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) in c:\DATA\Pro
jects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Dialect\Dialect.cs:Zeile
173.
bei NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) i
n c:\DATA\Projects\nhibernate\2.0.x\copy1\nhibernate\src\NHibernate\Cfg\Configur
ation.cs:Zeile 428.



Hello here ist my configuration:

Quote:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>

<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.Oracle9Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.OracleDataClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Data source=***@ip/dbname; User Id=***;Password=***;"
/>
</nhibernate>
</configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 7:38 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I just tried your mapping and your class and typhos was right, you either have to use type "int" or "Int32". Try this mapping:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="DBHibernate.Storage, DBHibernate" table="STORAGE">
    <id name="Id" column="STORAGE_ID" type="int">
      <generator class="assigned" />
    </id>
    <property name="Tower" column="TOWER" type="int" length="40"/>
    <property name="Side" type="String" length="40"/>
    <property name="Area" type="int"/>
    <property name="Tray" type="String" length="40"/>
    <property name="Size" type="int"/>
  </class>
</hibernate-mapping>

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 8:05 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
wolli wrote:
I just tried your mapping and your class and typhos was right, you either have to use type "int" or "Int32". Try this mapping:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="DBHibernate.Storage, DBHibernate" table="STORAGE">
    <id name="Id" column="STORAGE_ID" type="int">
      <generator class="assigned" />
    </id>
    <property name="Tower" column="TOWER" type="int" length="40"/>
    <property name="Side" type="String" length="40"/>
    <property name="Area" type="int"/>
    <property name="Tray" type="String" length="40"/>
    <property name="Size" type="int"/>
  </class>
</hibernate-mapping>


Thanks for your help, but now there is another problem:

I get a key not found exception in class Dialect.cs (line 173) instead of a defined primary key in the table storage on the DB. Is this Problem on the DB or on my Hibernate Code.

The logging Output is:

Quote:

78 [10] INFO NHibernate.Cfg.Environment (null) - NHibernate 2.0.0.1001 (2.0.0.10
01)
109 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration sectio
n not found in application configuration file
109 [10] INFO NHibernate.Cfg.Environment (null) - Bytecode provider name : lcg
109 [10] INFO NHibernate.Cfg.Environment (null) - Using reflection optimizer
125 [10] INFO NHibernate.Cfg.Configuration (null) - Searching for mapped documen
ts in assembly: DBHibernate
125 [10] INFO NHibernate.Cfg.Configuration (null) - checking mappings queue
125 [10] INFO NHibernate.Cfg.Configuration (null) - processing one-to-many assoc
iation mappings
125 [10] INFO NHibernate.Cfg.Configuration (null) - processing one-to-one associ
ation property references
125 [10] INFO NHibernate.Cfg.Configuration (null) - processing foreign key const
raints
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 9:32 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Quote:
109 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration section not found in application configuration file


Are you sure, that you're config is really used ? Check if it's flagged as "Embedded Resource". Do you use App.config/Web.config or a separate hibernate.cfg.xml file ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 1:51 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
wolli wrote:
Quote:
109 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration section not found in application configuration file


Are you sure, that you're config is really used ? Check if it's flagged as "Embedded Resource". Do you use App.config/Web.config or a separate hibernate.cfg.xml file ?



How can I check what config file is really used?

In my code I use the App.config an it is flagged as "Embedded Resource".


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 3:09 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
kumpfi wrote:
wolli wrote:
Quote:
109 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration section not found in application configuration file


Are you sure, that you're config is really used ? Check if it's flagged as "Embedded Resource". Do you use App.config/Web.config or a separate hibernate.cfg.xml file ?



How can I check what config file is really used?

In my code I use the App.config an it is flagged as "Embedded Resource".


Hello now if found in another example of nhibernate another App-config. I got this file and fit it to my project:

Code:
<configuration>
  <configSections>
    <section
      name="hibernate-configuration"
      type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
    />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
      <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
      <property name="default_schema">XXXXXX</property>
      <property name="connection.connection_string">Data source=XXXXXXXXX;User Id=XXXXXX;Password=XXXXXX;</property>
      <property name="show_sql">true</property>
      <mapping assembly="DBHibernate" />
    </session-factory>
  </hibernate-configuration>
</configuration>


Now the hibernate-config Section is not found info is no longer present.

But i got a lot of exception i shoult declare the methodes in my Storage.cs class as virtual. Why do i have to do this? I don't think, that this is right, but i have done ist to see what happens.

I got the following log output:

78 [10] INFO NHibernate.Cfg.Environment (null) - NHibernate 2.0.0.1001 (2.0.0.10
01)
109 [10] INFO NHibernate.Cfg.Environment (null) - Bytecode provider name : lcg
109 [10] INFO NHibernate.Cfg.Environment (null) - Using reflection optimizer
140 [10] INFO NHibernate.Cfg.Configuration (null) - Searching for mapped documen
ts in assembly: DBHibernate
140 [10] INFO NHibernate.Cfg.Configuration (null) - Mapping resource: DBHibernat
e.Storage.hbm.xml
187 [10] INFO NHibernate.Dialect.Dialect (null) - Using dialect: NHibernate.Dial
ect.Oracle9Dialect
1000 [10] INFO NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapping class: DBHib
ernate.Storage -> STORAGE
1015 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: Id
-> STORAGE_ID, type: Int32
1031 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: To
wer -> TOWER, type: Int32
1031 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: Si
de -> Side, type: String
1031 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: Ar
ea -> Area, type: Int32
1031 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: Tr
ay -> Tray, type: String
1031 [10] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder (null) - Mapped property: Size -> Size, type: Int32
1046 [10] INFO NHibernate.Cfg.Configuration (null) - checking mappings queue
1046 [10] INFO NHibernate.Cfg.Configuration (null) - processing one-to-many asso
ciation mappings
1046 [10] INFO NHibernate.Cfg.Configuration (null) - processing one-to-one assoc
iation property references
1046 [10] INFO NHibernate.Cfg.Configuration (null) - processing foreign key cons
traints
1062 [10] INFO NHibernate.Dialect.Dialect (null) - Using dialect: NHibernate.Dialect.Oracle9Dialect
1062 [10] INFO NHibernate.Exceptions.SQLExceptionConverterFactory (null) - Using
dialect defined converter
1062 [10] INFO NHibernate.Connection.ConnectionProviderFactory (null) - Initializing connection provider:
NHibernate.Connection.DriverConnectionProvider
1062 [10] INFO NHibernate.Connection.ConnectionProvider (null) - Configuring Con
nectionProvider
1078 [10] ERROR NHibernate.Util.ReflectHelper (null) - Could not load type Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess.
System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAcc
ess' or one of its dependencies. The system cannot find the file specified.
File name: 'Oracle.DataAccess'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Bool
ean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence as
semblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName n
ame, Boolean throwOnError) in D:\Projekte\ExternalDLLs\hibernate\HibSrc\src\NHib
ernate\Util\ReflectHelper.cs:line 260

=== Pre-bind state information ===
LOG: User = XXXXXXXXXXXXXXXXXXX
LOG: DisplayName = Oracle.DataAccess
(Partial)
LOG: Appbase = file:///D:/Projekte/Scheibenlager/Projekt_VS/TestHibernate/TestHi
bernate/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : NHibernate, Version=2.0.0.1001, Culture=neutral, PublicKeyTok
en=aa95f207798dfdb4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Projekte\Scheibenlager\Projekt_VS\
TestHibernate\TestHibernate\bin\Debug\DBHibernate.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

1109 [10] ERROR NHibernate.Util.ReflectHelper (null) - Could not load type Oracle.DataAccess.Client.OracleCommand, Oracle.DataAccess.
System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. The system cannot find the file specified.
File name: 'Oracle.DataAccess'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence as
semblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName n
ame, Boolean throwOnError) in D:\Projekte\ExternalDLLs\hibernate\HibSrc\src\NHibernate\Util\ReflectHelper.cs:line 260

=== Pre-bind state information ===
LOG: User = XXXXXXXXXXXXXXXXXXXX
LOG: DisplayName = Oracle.DataAccess
(Partial)
LOG: Appbase = file:///D:/Projekte/Scheibenlager/Projekt_VS/TestHibernate/TestHibernate/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : NHibernate, Version=2.0.0.1001, Culture=neutral, PublicKeyTok
en=aa95f207798dfdb4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Projekte\Scheibenlager\Projekt_VS\
TestHibernate\TestHibernate\bin\Debug\DBHibernate.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2
.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partia
l, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 3:27 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Back to square one, I get the same log message in my application. So this doesn't seem to be the problem, but I just found this and I think you use 2.0.x:

http://forum.hibernate.org/viewtopic.php?t=985289

Quote:
Initialization time


* <nhibernate> section is ignored, using <hibernate-configuration> section (note that they have different XML formats)
* Configuration values are no longer prefixed by "hibernate.", if before you would specify "hibernate.dialect", now you specify just "dialect"



According to this, you have to use this format:

Code:
<configSections>
     <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>

   <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <bytecode-provider type="lcg"/>
      <reflection-optimizer use="true"/>
      <session-factory name="NHibernate.Test">
         <property name="connection.provider">NHibernate.Test.DebugConnectionProvider, NHibernate.Test</property>
         <property name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider, NHibernate</property>
         <property name="cache.use_query_cache">true</property>
         <property name="prepare_sql">false</property>
         <property name="query.startup_check">false</property>
         <!--
            The valid strings for Isolation can be found in the documentation for the System.Data.IsolationLevel
            Enumeration documentation.
            Use the member names - not the values.
         -->
         <property name="connection.isolation">ReadCommitted</property>

         <!-- This is the System.Data.dll provider for MSSQL Server -->
         <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
         <property name="connection.connection_string">
            Server=(local);initial catalog=nhibernate;Integrated Security=SSPI
         </property>
         <property name="show_sql">false</property>
         <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
         <property name="use_outer_join">true</property>
         <property name="command_timeout">444</property>
         <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
         <property name="adonet.wrap_result_sets">false</property>
      </session-factory>
   </hibernate-configuration>

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 4:39 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
wolli wrote:
Back to square one, I get the same log message in my application. So this doesn't seem to be the problem, but I just found this and I think you use 2.0.x:

http://forum.hibernate.org/viewtopic.php?t=985289

Quote:
Initialization time


* <nhibernate> section is ignored, using <hibernate-configuration> section (note that they have different XML formats)
* Configuration values are no longer prefixed by "hibernate.", if before you would specify "hibernate.dialect", now you specify just "dialect"



According to this, you have to use this format:

Code:
<configSections>
     <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>

   <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <bytecode-provider type="lcg"/>
      <reflection-optimizer use="true"/>
      <session-factory name="NHibernate.Test">
         <property name="connection.provider">NHibernate.Test.DebugConnectionProvider, NHibernate.Test</property>
         <property name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider, NHibernate</property>
         <property name="cache.use_query_cache">true</property>
         <property name="prepare_sql">false</property>
         <property name="query.startup_check">false</property>
         <!--
            The valid strings for Isolation can be found in the documentation for the System.Data.IsolationLevel
            Enumeration documentation.
            Use the member names - not the values.
         -->
         <property name="connection.isolation">ReadCommitted</property>

         <!-- This is the System.Data.dll provider for MSSQL Server -->
         <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
         <property name="connection.connection_string">
            Server=(local);initial catalog=nhibernate;Integrated Security=SSPI
         </property>
         <property name="show_sql">false</property>
         <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
         <property name="use_outer_join">true</property>
         <property name="command_timeout">444</property>
         <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
         <property name="adonet.wrap_result_sets">false</property>
      </session-factory>
   </hibernate-configuration>


Hello Wolfgang,

i did it like zu told me an i am at the beginning of the thread. I have the following output of logger:

Quote:
93 [10] INFO NHibernate.Cfg.Environment (null) - NHibernate 2.0.0.1001 (2.0.0.10
01)
125 [10] INFO NHibernate.Cfg.Environment (null) - hibernate-configuration sectio
n not found in application configuration file
125 [10] INFO NHibernate.Cfg.Environment (null) - Bytecode provider name : lcg
125 [10] INFO NHibernate.Cfg.Environment (null) - Using reflection optimizer
171 [10] INFO NHibernate.Cfg.Configuration (null) - Searching for mapped documen
ts in assembly: DBHibernate
171 [10] INFO NHibernate.Cfg.Configuration (null) - Mapping resource: DBHibernat
e.Storage.hbm.xml
218 [10] ERROR NHibernate.Cfg.Configuration (null) - Could not compile the mappi
ng document: DBHibernate.Storage.hbm.xml
NHibernate.MappingException: Could not compile the mapping document: DBHibernate
.Storage.hbm.xml ---> System.Collections.Generic.KeyNotFoundException: The given
key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) in D:\Projekte\
ExternalDLLs\hibernate\HibSrc\src\NHibernate\Dialect\Dialect.cs:line 173
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) in
D:\Projekte\ExternalDLLs\hibernate\HibSrc\src\NHibernate\Cfg\Configuration.cs:l
ine 428
--- End of inner exception stack trace ---


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 4:49 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Quote:
But i got a lot of exception i shoult declare the methodes in my Storage.cs class as virtual. Why do i have to do this? I don't think, that this is right, but i have done ist to see what happens.


This is because of hibernate defaults to lazy loading. You can turn lazy loading off on your class with lazy="false".

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 5:00 am 
Newbie

Joined: Thu May 08, 2008 3:14 am
Posts: 16
wolli wrote:
Quote:
But i got a lot of exception i shoult declare the methodes in my Storage.cs class as virtual. Why do i have to do this? I don't think, that this is right, but i have done ist to see what happens.


This is because of hibernate defaults to lazy loading. You can turn lazy loading off on your class with lazy="false".


Doing lazy="false" has no effect. I get the same exception.
I am sorry, but meanwhile i think i am too stupid using nhibernate, in my mind it is a simple expample and i don't get it running.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 5:07 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Since we discussed a lot of changes, can you repost the current configuration and mapping ?

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.