0

I'm using fluent hibernate 1.2.0.712 and nhibernate 3.2.0.4000 in my mvc project as an OR mapper, the problem is : this is my oJob object:

public class Job{

    virtual public Enquiry Enquiry { get; set; }
    virtual public long Id { get; set; }
}

and this is Enquiry:

public class Enquiry {

virtual public long Id { get; set; }
}

and here is JobMap:

 public  class JobMap: ClassMap<Job>
{
   public JobMap()
   {
       Schema("dbo");

       Id(p => p.Id)
           .Column("Id");

       References(p => p.Enquiry);
    }
}

i expect that each job has exactly one enquiry

but sometimes that i check sql server i see there are some records in job table with different ids that all have the same enquiryid

and i checked it many times and dont know when exactly it happens, what is the problem?

4

1 回答 1

0

你必须改变你的映射:改变

References(p => p.Enquiry);

经过

HasOne(p => p.Enquiry);
于 2012-04-21T08:50:16.620 回答