-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to mapping parent from different class
PostPosted: Fri May 18, 2012 4:50 am 
Newbie

Joined: Fri May 18, 2012 4:17 am
Posts: 1
Hi, I'm new in nhibernate and I need help.

I have:
Code:
public abstract class AreaBase : BusinessEntity
{
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }      
}

public class OArea : AreaBase
{
    public virtual Regions Region { get; set; }
}

public class Regions : List<RegionsArea>
{
}

public class RegionsArea : AreaBase
{
    public virtual Country Country { get; set; }
}


table:
Code:
CREATE TABLE [dbo].[tArea]
(
    [Id] [dbo].[ID] IDENTITY(1, 1) NOT NULL PRIMARY KEY,
    [FirstName] varchar(50) NOT NULL,
    [LastName] varchar(50) NOT NULL,
    [ParentId] [dbo].[ID] NULL,
    CONSTRAINT [FK_tArea_tArea] FOREIGN KEY ([ParentId]) REFERENCES [tArea]([Id])
)


I wrote:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping assembly="Entities" namespace="Entities.Profiles" xmlns="urn:nhibernate-mapping-2.2">
  <class name="AreaBase" table="tArea">
    <id name="Id">
      <column name="Id" sql-type="bigint"/>
      <generator class="native"/>
    </id>
    <property name="FirstName" column="FirstName"/>
    <property name="LastName" column="LastName"/>
  </class>
</hibernate-mapping>


but don't no idea have to mapping ParentId from OArea:AreaBase. (Region RegionsArea)
Please help!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.