Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I am having a problem with configuring session factory
I am trying to execute following code and I am getting exception on AddXmlFile
Code:
string path = HostingEnvironment.MapPath(
System.Configuration.ConfigurationManager
.AppSettings["NHibernateConfigurationFile"]);
Configuration cfg = new Configuration().Configure(path);
cfg.AddXmlFile(HostingEnvironment.MapPath("/NhibernateMapping/Invoice.hbm.xml"));
////cfg.AddXmlFile(HostingEnvironment.MapPath("~/bin/LineItem.hbm.xml"));
SessionFactory = cfg.BuildSessionFactory();
Hibernate version: 1.2.1
Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
schema=""
default-cascade="none"
auto-import="true"
assembly="Intelliun.Core" namespace="Intelliun.Core.Entities.billing"
>
<class name="Invoice"
table="INVOICE"
lazy="true"
>
<id name = "ID"
type = "Guid"
column="VEOID"
unsaved-value="0"
access="property"
>
<generator class="guid.comb"></generator>
</id>
<property name = "number"
column = "NUMBER"
type = "String"
access="field.camelcase-underscore"
/>
<property name = "date"
column = "DATE"
type = ""
access="field.camelcase-underscore"
/>
<property name = "unpaidBalance"
column = "UNPAID_BALANCE"
type = ""
access="field.camelcase-underscore"
/>
<set name="lineItems" table="LINE_ITEM" lazy="true">
<key column="VEOID"/>
<composite-element class="Intelliun.Core.Entities.billing.LineItem">
<property name = "description"
column = "Description"
type = "String"
access="field.camelcase-underscore"
/>
<property name = "unitPrice"
column = "UnitPrice"
type = ""
access="field.camelcase-underscore"
/>
<property name = "quantity"
column = "Quantity"
type = ""
access="field.camelcase-underscore"
/>
</composite-element>
</set>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
could not interpret type:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: NHibernate.MappingException: could not interpret type:
Source Error:
Line 25: .AppSettings["NHibernateConfigurationFile"]);
Line 26: Configuration cfg = new Configuration().Configure(path);
Line 27: cfg.AddXmlFile(HostingEnvironment.MapPath("/NhibernateMapping/Invoice.hbm.xml"));
Line 28: ////cfg.AddXmlFile(HostingEnvironment.MapPath("~/bin/LineItem.hbm.xml"));
Line 29:
Source File: C:\VE4_0\server\namespace\homes\Web\codegen\Demo\NhibernateSessionModule\NHibernateHelper.cs Line: 27
Stack Trace:
[MappingException: could not interpret type: ]
NHibernate.Cfg.HbmBinder.GetTypeFromXML(XmlNode node) +710
NHibernate.Cfg.HbmBinder.BindSimpleValue(XmlNode node, SimpleValue model, Boolean isNullable, String path, Mappings mappings) +59
NHibernate.Cfg.HbmBinder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings) +928
NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings) +4003
NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings) +478
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +103
[MappingException: Could not compile the mapping document: C:\VE4_0\server\namespace\homes\Web\codegen\Demo\AR200\NhibernateMapping\Invoice.hbm.xml]
NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) +62
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +205
NHibernate.Cfg.Configuration.ProcessMappingsQueue() +38
NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document) +42
NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name) +60
NHibernate.Cfg.Configuration.AddXmlFile(String xmlFile) +158
Intelliun.NHibernateExtensions.NHibernateHelper..cctor() in C:\VE4_0\server\namespace\homes\Web\codegen\Demo\NhibernateSessionModule\NHibernateHelper.cs:27
[Exception: NHibernate initialization failed]
Intelliun.NHibernateExtensions.NHibernateHelper..cctor() in C:\VE4_0\server\namespace\homes\Web\codegen\Demo\NhibernateSessionModule\NHibernateHelper.cs:35
[TypeInitializationException: The type initializer for 'Intelliun.NHibernateExtensions.NHibernateHelper' threw an exception.]
Intelliun.NHibernateExtensions.NHibernateSessionModule.Application_EndRequest(Object sender, EventArgs e) in C:\VE4_0\server\namespace\homes\Web\codegen\Demo\NhibernateSessionModule\NHibernateSessionModule.cs:42
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433