I've changed my mapping so that it doesn't refer to PostBase at all
anymore. I just have a mapping file for Post and one for Comment, then
because they both inherit from PostBase, the table columns are
automatically mapped to the ones of PostBase.

I think that was the solution, no ?

On 19 mar, 16:06, graphicsxp <[email protected]> wrote:
> Is this new to nhibernate 2.0 ? I can't find anything about that in my
> nhibernate 1.2 book ....
>
> There is a reference to <joined-subclass> but that implies using the
> Table-per-subclass strategy, which I don't want to do.
>
> Do you have an example on how to use extends and <join>
>
> Thanks
>
> On 19 mar, 15:34, Fabio Maulo <[email protected]> wrote:
>
> > you should use extends and <join>
>
> > 2009/3/19 graphicsxp <[email protected]>
>
> > > Hello,
>
> > > I have an exception Duplicate class/entity mapping Comp.PostBase.
>
> > > This is because I have two mapping files for two different tables but
> > > they both map to two classes that share the same base class :
>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
> > >  <class name="Comp.PostBase, Comp" table="Comment" lazy="true"
> > > discriminator-value="POST_BASE" abstract="true">
> > >    <id name="Id" column="PostID">
> > >      <generator class="native"/>
> > >    </id>
>
> > >    <discriminator column="Type" type="string" />
>
> > >    <property name="DateCreated" type="date" column="DateCreated" />
>
> > >    <subclass name="Comp.CommentPost, Comp" discriminator-
> > > value="COMMENT">
> > >      <property name="ParentId" type="Comp.CommentPost, Comp"
> > > column="ParentId" />
> > >      <many-to-one name="thePost" cascade="none" column="PostID" not-
> > > null="true" />
> > >    </subclass>
>
> > >  </class>
> > > </hibernate-mapping>
>
> > > AND
>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
> > >  <class name="Comp.PostBase, Comp" table="Post" lazy="true"
> > > discriminator-value="POST_BASE" abstract="true">
> > >    <id name="Id" column="PostID">
> > >      <generator class="native"/>
> > >    </id>
>
> > >    <discriminator column="Type" type="string" />
>
> > >    <property name="DateCreated" type="date" column="DateCreated" />
>
> > >    <!-- Description of a Post entity -->
> > >    <subclass name="Comp.Post, Comp" discriminator-value="POST">
> > >      <property name="Headline" type="string" length="500"
> > > column="Headline" />
> > >      <property name="URL" type="string" length="1000" column="URL" />
> > >      <property name="AnalystComment" type="string"
> > > column="AnalystComment" />
> > >      <bag  name="Comments" inverse="true" cascade="all" lazy="true">
> > >        <key column="CommentID" />
> > >        <one-to-many class="Comp.CommentPost, Comp" />
> > >      </bag>
> > >    </subclass>
>
> > >  </class>
> > > </hibernate-mapping>
>
> > > That seems to be a big issue for me. How can I do that ?
>
> > --
> > Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to