Unless your mapping files are in different assemblies, this is wrong:
configuration.AddAssembly(typeof (RptSourceGroup).Assembly);
configuration.AddAssembly(typeof (RptSource).Assembly);
Diego
On Tue, Aug 31, 2010 at 14:57, PLen <[email protected]> wrote:
> Hello,
>
> I have two mapping files defined as:
>
> <?xml version="1.0" encoding="utf-8"?>
> <hibernate-mapping assembly="FirstSample"
> namespace="FirstSample.Domain" xmlns="urn:nhibernate-mapping-2.2">
> <class name="RptSourceGroup" table="RPT_SOURCE_GROUP" lazy="true" >
> <!--
> <id name="GroupId" column="GROUP_ID" />
> <id name="GroupId" type="Int64" column="GROUP_ID">
> <generator class="assigned" />
> </id>
> -->
> <id name="GroupId" type="Int64" column="GROUP_ID">
> <generator class="sequence">
> <param name="sequence">RPT_SOURCE_GROUP_SEQ</param>
> </generator>
> </id>
> <property name="Name" column="NAME" />
> <property name="Country" column="COUNTRY" />
> <property name="Year" column="YEAR" />
> <property name="Asset" column="ASSET" />
> <property name="Frn" column="FRN" />
> <property name="MediaType" column="MEDIA_TYPE" />
> <property name="Annotation" column="ANNOTATION" />
> <property name="Status" column="STATUS" />
> <property name="Created" column="CREATED" />
> </class>
> </hibernate-mapping>
>
> and
>
> <?xml version="1.0" encoding="utf-8"?>
> <hibernate-mapping assembly="FirstSample"
> namespace="FirstSample.Domain" xmlns="urn:nhibernate-mapping-2.2">
> <class name="RptSource" table="RPT_SOURCE" lazy="true" >
> <id name="SourceId" type="Int64" column="SOURCE_ID">
> <generator class="sequence">
> <param name="sequence">RPT_SOURCE_SEQ</param>
> </generator>
> </id>
> <many-to-one name="RptSourceGroup" column="GROUP_ID" />
> <property name="Name" column="NAME" />
> <property name="Body" column="BODY" />
> <property name="SourcePath" column="SOURCE_PATH" />
> </class>
> </hibernate-mapping>
>
> They share the same namespace but have different class names. In the
> code where I am configuring my session (NHibernateHelper class), I
> have the following:
>
> var configuration = new Configuration();
> configuration.Configure();
> configuration.AddAssembly(typeof (RptSourceGroup).Assembly);
> configuration.AddAssembly(typeof (RptSource).Assembly);
>
> When I run my app the following error is thrown during the second
> AddAssembly call:
>
> ERROR: NHibernate.MappingException: Could not compile the mapping
> document: Firs
> tSample.Mappings.RptSourceGroup.hbm.xml --->
> NHibernate.DuplicateMappingExceptio
> n: Duplicate class/entity mapping FirstSample.Domain.RptSourceGroup
> at NHibernate.Cfg.Mappings.AddClass(PersistentClass
> persistentClass)
> at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(XmlNode node,
> HbmClass c
> lassSchema, IDictionary`2 inheritedMetas)
> at
> NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddRootClasses(XmlNode
> pare
> ntNode, IDictionary`2 inheritedMetas)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(XmlNode
> node)
> at
> NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument
> doc)
> --- End of inner exception stack trace ---
> at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
> at
> NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument
> doc)
>
> ............................................
>
> Any clues as to why this is happening?
>
> Thanks - Peter
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.