Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 1.2.1.4000
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="QuickStart" assembly="QuickStart">
<class name="Cat" table="Cat" lazy="false">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by NHibernate with the UUID pattern. -->
<id name="Id" type="Int64" column="CatId" unsaved-value="0">
<generator class="identity"/>
</id>
<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="Name">
<column name="Name" length="16" not-null="true" />
</property>
<property name="Sex" />
<property name="Weight" />
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="QuickStart" assembly="QuickStart">
<class name="House" table="House" lazy="false">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by NHibernate with the UUID pattern. -->
<id name="Id" type="Int64" column="HouseID" unsaved-value="0">
<generator class="native"/>
</id>
<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="LastName">
<column name="LastName" length="16" not-null="true" />
</property>
<bag name="Cats" lazy="false">
<key column="CatID" />
<one-to-many class="Cat" />
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[DuplicateMappingException: Duplicate collection role mapping QuickStart.House.Cats]
NHibernate.Cfg.Mappings.AddCollection(Collection collection) +111
NHibernate.Cfg.HbmBinder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings) +235
NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings) +2404
NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings) +390
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +64
[MappingException: Could not compile the mapping document: QuickStart.House.hbm.xml]
NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) +38
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +150
NHibernate.Cfg.Configuration.ProcessMappingsQueue() +12
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) +169
NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) +177
NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly) +97
QuickStart.NHibernateHelper..cctor() in C:\Workspace\QuickStart\QuickStart\Default.aspx.cs:87
[TypeInitializationException: The type initializer for 'QuickStart.NHibernateHelper' threw an exception.]
QuickStart.NHibernateHelper.GetCurrentSession() in C:\Workspace\QuickStart\QuickStart\Default.aspx.cs:103
QuickStart._Default.Page_Load(Object sender, EventArgs e) in C:\Workspace\QuickStart\QuickStart\Default.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
Name and version of the database you are using: SQL Server 2005 express (named instance)
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
I'm very new to NHibernate. Please help me. I'm trying to get the QuickStart sample up and running with minor changes. I have a table House which shares a 1 to many relationship with the table Cat. I have two mapping files one for Cat and one for House, which I've attached with this message. I'm not able to get past this issue. Please help.