-->
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.  [ 3 posts ] 
Author Message
 Post subject: Configuration problem
PostPosted: Tue Apr 01, 2008 4:14 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
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



Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 5:02 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
for some reason xml file added this way does not work, however if I make it embeded resource and then do AddAssembly then it is ok.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:28 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
I tried it in my project and if I use type="", then I get the same error, even when the mapping is an embedded resource.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.