I am trying to make a mapping for 2 new classes Company, Country
Where company has many users and country contains many companies, but each user exists in one company and each company exists in one country.
After i did the mapping i tried running the project but an error occurred
Quote:
Exception Details: System.Xml.Schema.XmlSchemaException: The 'lazy' attribute is not declared.
Quote:
NHibernate 1.0.4:
Quote:
Company
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Cuyahoga.Core.Domain.Company, Cuyahoga.Core" table="cuyahoga_company">
<cache usage="read-write" />
<id name="Id" column="company_Id" type="Int32" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="CompanyName" column="company_name" type="String" length="100" />
<property name="Address1" column="address1" type="String" length="100" />
<property name="Address2" column="address2" type="String" length="100" />
<property name="Phone" column="phone" type="String" length="25" />
<property name="Fax" column="fax" type="String" length="25" />
<property name="City" column="city" type="String" length="100" />
<property name="Website" column="website" type="String" length="100" />
<property name="State" column="state" type="String" length="50" />
<property name="PostalCode" column="postalcode" type="String" length="20" />
<property name="Industry" column="industry" type="String" length="250" />
<property name="InsertTimestamp" column="inserttimestamp" type="DateTime" />
<property name="UpdateTimestamp" column="updatetimestamp" type="DateTime" />
<bag name="Users" cascade="none" lazy="true">
<key column="companyId"/>
<one-to-many class="Cuyahoga.Core.Domain.User, Cuyahoga.Core.Domain.Company " />
</bag>
<many-to-one name="CompanyCountry" class="Cuyahoga.Core.Domain.Country, Cuyahoga.Core.Domain.Company" column="countryid" cascade="all"/>
</class>
</hibernate-mapping>
Quote:
Country
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Cuyahoga.Core.Domain.Country, Cuyahoga.Core" table="cm_country">
<cache usage="read-write" />
<id name="Id" column="Country_Id" type="Int32" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="Name" column="Country_Name" type="String" length="50" />
<property name="Code" column="Country_Code" type="String" length="50" />
<bag name="Companies" cascade="all" lazy="true">
<key column="countryid"/>
<one-to-many class="Cuyahoga.Core.Domain.Company, Cuyahoga.Core.Domain.Country" />
</bag>
</class>
</hibernate-mapping>
Quote:
User
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Cuyahoga.Core.Domain.User, Cuyahoga.Core" table="cuyahoga_user"
proxy="Cuyahoga.Core.Domain.User, Cuyahoga.Core">
<cache usage="read-write" />
<id name="Id" column="userid" type="Int32" unsaved-value="-1">
<generator class="native">
<param name="sequence">cuyahoga_user_userid_seq</param>
</generator>
</id>
<timestamp name="UpdateTimestamp" column="updatetimestamp" />
<property name="UserName" column="username" type="String" length="50" />
<property name="Password" column="password" type="String" length="100" />
<property name="FirstName" column="firstname" type="String" length="100" not-null="false" />
<property name="LastName" column="lastname" type="String" length="100" not-null="false" />
<property name="Title" column="title" type="String" length="50" />
<property name="Email" column="email" type="String" length="100" />
<property name="Website" column="website" type="String" length="100" />
<property name="TimeZone" column="timezone" type="Int32" />
<property name="IsActive" column="isactive" type="Boolean" length="100" />
<property name="LastLogin" column="lastlogin" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" />
<property name="LastIp" column="lastip" type="String" length="40" />
<property name="InsertTimestamp" column="inserttimestamp" type="DateTime" />
<many-to-one name="UserCompany" class="Cuyahoga.Core.Domain.Company, Cuyahoga.Core.Domain.User" column="companyid" cascade="all" lazy="true"/>
<bag name="Roles" table="cuyahoga_userrole" cascade="none" lazy="true">
<cache usage="read-write" />
<key column="userid" />
<many-to-many class="Cuyahoga.Core.Domain.Role, Cuyahoga.Core" column="roleid" outer-join="true" />
</bag>
</class>
</hibernate-mapping>
Quote:
stack trace
Code:
[XmlSchemaException: The 'lazy' attribute is not declared.]
NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventArgs args) +7
System.Xml.Schema.BaseValidator.SendValidationEvent(XmlSchemaException e, XmlSeverityType severity) +58
System.Xml.Schema.XsdValidator.ValidateStartElement() +840
System.Xml.Schema.XsdValidator.ProcessElement(Object particle) +325
System.Xml.Schema.XsdValidator.ValidateElement() +189
System.Xml.Schema.XsdValidator.Validate() +66
System.Xml.XmlValidatingReaderImpl.ProcessCoreReaderEvent() +115
System.Xml.XmlValidatingReaderImpl.Read() +43
System.Xml.XmlValidatingReader.Read() +12
System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +557
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +50
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +162
System.Xml.XmlDocument.Load(XmlReader reader) +96
NHibernate.Cfg.Configuration.LoadMappingDocument(XmlTextReader hbmReader) +177
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream) +64
[MappingException: The 'lazy' attribute is not declared.]
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream) +173
NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering) +243
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +158
Castle.Facilities.NHibernateIntegration.NHibernateFacility.RegisterAssemblies(Configuration cfg, IConfiguration facilityConfig) +182
Castle.Facilities.NHibernateIntegration.NHibernateFacility.ConfigureFactories(IConfiguration config, ISessionFactoryResolver sessionFactoryResolver, Boolean firstFactory) +544
Castle.Facilities.NHibernateIntegration.NHibernateFacility.ConfigureFacility() +357
Castle.Facilities.NHibernateIntegration.NHibernateFacility.Init() +51
Castle.MicroKernel.Facilities.AbstractFacility.Init(IKernel kernel, IConfiguration facilityConfig) +47
Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility facility) +202
Castle.Windsor.WindsorContainer.AddFacility(String key, IFacility facility) +38
Castle.Windsor.Installer.DefaultComponentInstaller.SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container) +307
Castle.Windsor.Installer.DefaultComponentInstaller.SetUp(IWindsorContainer container, IConfigurationStore store) +46
Castle.Windsor.WindsorContainer.RunInstaller() +75
Castle.Windsor.WindsorContainer..ctor(IConfigurationInterpreter interpreter) +150
Cuyahoga.Web.Components.CuyahogaContainer..ctor() in E:\WEb Site\Web\Components\CuyahogaContainer.cs:17
Cuyahoga.Web.Global.Application_Start(Object sender, EventArgs e) in E:\WEb Site\Web\Global.asax.cs:41
Quote:
Ms Sql 2005 sp1
Quote:
SQL
Quote:
company
Code:
CREATE TABLE [dbo].[cuyahoga_company](
[company_id] [int] IDENTITY(1,1) NOT NULL,
[company_name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[address1] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[address2] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[phone] [nvarchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[fax] [nvarchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[city] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[website] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[state] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[countryid] [int] NULL,
[postalcode] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[industry] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[inserttimestamp] [datetime] NULL CONSTRAINT [DF_cuyahoga_company_inserttimestamp] DEFAULT (getdate()),
[updatetimestamp] [datetime] NULL CONSTRAINT [DF_cuyahoga_company_updatetimestamp] DEFAULT (getdate()),
CONSTRAINT [PK_cuyahoga_company] PRIMARY KEY CLUSTERED
(
[company_id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
Code:
ALTER TABLE [dbo].[cuyahoga_company] WITH CHECK ADD CONSTRAINT [FK_cuyahoga_company_cm_country] FOREIGN KEY([countryid])
REFERENCES [dbo].[cm_country] ([Country_Id])
Quote:
country
Code:
CREATE TABLE [dbo].[cm_country](
[Country_Id] [int] IDENTITY(1,1) NOT NULL,
[Country_Code] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Country_Name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_cm_country] PRIMARY KEY CLUSTERED
(
[Country_Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
Quote:
user
Code:
CREATE TABLE [dbo].[cuyahoga_user](
[userid] [int] IDENTITY(1,1) NOT NULL,
[username] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[password] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[firstname] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[lastname] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[title] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[email] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[website] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[timezone] [int] NOT NULL CONSTRAINT [DF__cuyahoga___timez__7E6CC920] DEFAULT ((0)),
[isactive] [bit] NULL,
[lastlogin] [datetime] NULL,
[lastip] [nvarchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[inserttimestamp] [datetime] NOT NULL CONSTRAINT [DF__cuyahoga___inser__7F60ED59] DEFAULT (getdate()),
[updatetimestamp] [datetime] NOT NULL CONSTRAINT [DF__cuyahoga___updat__00551192] DEFAULT (getdate()),
[companyId] [int] NULL,
CONSTRAINT [PK_user] PRIMARY KEY CLUSTERED
(
[userid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
CONSTRAINT [UC_user_username] UNIQUE NONCLUSTERED
(
[username] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
Code:
ALTER TABLE [dbo].[cuyahoga_user] WITH CHECK ADD CONSTRAINT [FK_cuyahoga_user_cuyahoga_company] FOREIGN KEY([companyId])
REFERENCES [dbo].[cuyahoga_company] ([company_id]
Debug level Hibernate log excerpt:Quote: