sorry, posted too early... Se my later post...

On 9 Mrz., 10:51, DL9999 <[email protected]> wrote:
> Hallo,
>
> I'm new to NHibernate and have some general questions about mapping of
> class-structures. I'm using mapping attributes...
>
> I have a base-class that is self-referencing by a parent_id. I tried
> this way:
>
> [Class(NameType = typeof(BaseClass), Table = "BASE")]
> class abstract BaseClass : MyEntity
> {
>     [Id(0, Name = "Id", Column = "ID")]
>     [Generator(1, Class = "hilo")]
>     public virtual long Id { get; set; }
>
>     [ManyToOne(Column = "PARENT_ID", ForeignKey = "FK_BASE_PARENT")]
>     public virtual BaseClass Parent { get; set; }
>
> }
>
> My intention was to inherit some classes from this abstract BaseClass
> which all are self-referencing throught the BaseClass dependency.
>
> I know that this is the wrong way (Hybernate throws an exception)
> because the "Parent"-property is by design the wrong type (BaseClass
> is abstract an can never be load)...
>
> So I tried this:
>
> [Class(NameType = typeof(BaseClass), Table = "BASE")]
> class abstract BaseClass : MyEntity
> {
>     [Id(0, Name = "Id", Column = "ID")]
>     [Generator(1, Class = "hilo")]
>     public virtual long Id { get; set; }
>
> [Property(1, Column = "PARENT_VERSION_BO_ID")]
>                 [Key(2, Column = "BO_ID", ForeignKey = 
> "FK_BO_PARENT_VERSION_BO")]
>                 public virtual long ParentVersionId { get; set; }
>     [ManyToOne(Column = "PARENT_ID", ForeignKey = "FK_BASE_PARENT")]
>     public virtual BaseClass Parent { get; set; }
>
>
>
> }- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

-- 
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