元素 命名空间“urn:nhibernate-mapping-2.2”中的“property”

dwtedx1 2012-04-25 06:25:30
元素 命名空间“urn:nhibernate-mapping-2.2”中的“property”。 的子元素 命名空间“urn:nhibernate-mapping-2.2”中的“generator”。 无效。应为可能元素的列表: 命名空间“urn:nhibernate-mapping-2.2”中的“meta, column, formula, type”。。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Xml.Schema.XmlSchemaValidationException: 元素 命名空间“urn:nhibernate-mapping-2.2”中的“property”。 的子元素 命名空间“urn:nhibernate-mapping-2.2”中的“generator”。 无效。应为可能元素的列表: 命名空间“urn:nhibernate-mapping-2.2”中的“meta, column, formula, type”。。

源错误:

行 16: static NHibernate_QYl()
行 17: {
行 18: sessionFactory = new Configuration().Configure().BuildSessionFactory();
行 19: }
行 20:


源文件: D:\work\LongQuan\LongQuan\LongQuan.Data\NHibernate_QYl.cs 行: 18

堆栈跟踪:

[XmlSchemaValidationException: 元素 命名空间“urn:nhibernate-mapping-2.2”中的“property”。 的子元素 命名空间“urn:nhibernate-mapping-2.2”中的“generator”。 无效。应为可能元素的列表: 命名空间“urn:nhibernate-mapping-2.2”中的“meta, column, formula, type”。。]

[MappingException: LongQuan.Data.Mapping.Department.hbm.xml(6,12): XML validation error: 元素 命名空间“urn:nhibernate-mapping-2.2”中的“property”。 的子元素 命名空间“urn:nhibernate-mapping-2.2”中的“generator”。 无效。应为可能元素的列表: 命名空间“urn:nhibernate-mapping-2.2”中的“meta, column, formula, type”。。]
NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) +88
NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventArgs args) +390
System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(ValidationEventHandler eventHandler, Object sender, XmlSchemaValidationException e, XmlSeverityType severity) +54
System.Xml.Schema.XmlSchemaValidator.ElementValidationError(XmlQualifiedName name, ValidationState context, ValidationEventHandler eventHandler, Object sender, String sourceUri, Int32 lineNo, Int32 linePos, XmlSchemaSet schemaSet) +761
System.Xml.Schema.XmlSchemaValidator.ValidateElementContext(XmlQualifiedName elementName, Boolean& invalidElementInContext) +4025704
System.Xml.Schema.XmlSchemaValidator.ValidateElement(String localName, String namespaceUri, XmlSchemaInfo schemaInfo, String xsiType, String xsiNil, String xsiSchemaLocation, String xsiNoNamespaceSchemaLocation) +142
System.Xml.XsdValidatingReader.ProcessElementEvent() +161
System.Xml.XsdValidatingReader.ProcessReaderEvent() +53
System.Xml.XsdValidatingReader.Read() +49
System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +57
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +20
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +131
System.Xml.XmlDocument.Load(XmlReader reader) +114
NHibernate.Cfg.Configuration.LoadMappingDocument(XmlReader hbmReader, String name) +300
NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String name) +45
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) +149
NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) +244
NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly) +211
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +201
NHibernate.Cfg.Configuration.DoConfigure(ISessionFactoryConfiguration factoryConfiguration) +1129
NHibernate.Cfg.Configuration.Configure() +111
LongQuan.Data.NHibernate_QYl..cctor() in D:\work\LongQuan\LongQuan\LongQuan.Data\NHibernate_QYl.cs:18

[TypeInitializationException: “LongQuan.Data.NHibernate_QYl”的类型初始值设定项引发异常。]
LongQuan.Data.NHibernate_QYl.GetCurrentSession() in D:\work\LongQuan\LongQuan\LongQuan.Data\NHibernate_QYl.cs:33
LongQuan.Services.ConcreteServices.CustomerAttachmentServices.Select() in D:\work\LongQuan\LongQuan\LongQuan.Services\ConcreteServices\CustomerAttachmentServices.cs:22
LongQuan.Web.Controllers.CustomerAttachmentsController.Index() in D:\work\LongQuan\LongQuan\LongQuan.Web\Controllers\CustomerAttachmentsController.cs:19
lambda_method(Closure , ControllerBase , Object[] ) +96
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8967997
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184


版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.272
...全文
555 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dwtedx1 2012-04-26
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="LongQuan.Data" namespace="LongQuan.Data">
<class name ="LongQuan.Entities.Dome, LongQuan.Entities" table="Dome">
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class ="native"></generator>
</id>

<property name="username" column ="username" type="string"/>

</class>
</hibernate-mapping>

是不是要所有的映射文件都要正确才能通过呀??
孟子E章 2012-04-25
  • 打赏
  • 举报
回复
LongQuan.Data.Mapping.Department.hbm.xml
文件格式错误,
In this article I want to discuss the lazy loading mechanism provided by NHibernate. It is recommended for maximum flexibility to define all relations in your domain as lazy loadable. This is the default behavior of NHibernate since version 1.2. But this can lead to some undesired effects if querying your data. Let's discuss these effects and how to avoid them. Term Paper AND Research Paper In my previous posts I showed how to prepare your system for NHibernate and how to implement a first NHibernate base application. This post is based on those two articles. Thesis AND Dissertation AND Essay The Domain Let's first define a simple domain. It shows part of an order entry system. I keep this model as simple as possible (a real domain model would be more complex) but it contains all aspects we want to discuss in this post. Below is the class diagram of our model We have an order entity which can be placed by a customer entity. Each order can have many order line entities. Each of the three entity types is uniquely identified by a property Id (surrogate key). The Mapping Files We have to write one mapping file per entity. It is recommended that you always have one mapping per file. Don't forget to set the Build Action of each mapping file to Embedded Resource. People often tend to forget it and the subsequent errors raised by NHibernate are not always obvious. Also do not forget to give the mapping files the correct name, that is *.hbm.xml where * denotes the placeholder for the entity name. The mapping for the Order entity might be implemented as follows mapping xmlns="urn:nhibernate-mapping-2.2" assembly="LazyLoadEagerLoad" namespace="LazyLoadEagerLoad.Domain"> <property name="OrderNumber"/> <property name="OrderDate"/> mapping>Analogous you can implement the mappings for the Customer entity mapping xmlns="urn:nhibernate-mapping-2.2" assembly="LazyLoadEagerLoad" namespace="LazyLoadEagerLoad.Domain"> <property name="CompanyName"/> mapping>and finally the mapping for the OrderLine entity. mapping xmlns="urn:nhibernate-mapping-2.2" assembly="LazyLoadEagerLoad" namespace="LazyLoadEagerLoad.Domain"> <property name="Amount"/> <property name="ProductName"/> mapping>

62,267

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧